/**
 * Form Builder V2 Styles
 * Grafana-style grid layout with drag-and-drop
 */

/* ===== MODAL OVERLAY & CONTAINER ===== */
.form-builder-v2-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.form-builder-v2-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    backdrop-filter: blur(4px);
}

.form-builder-v2-container {
    position: relative;
    background: #1f1f1f;
    border-radius: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    flex-direction: column;
    box-shadow: none;
    animation: slideUp 0.3s ease;
    color: #e0e0e0;
}

/* ===== HEADER ===== */
.form-builder-v2-header {
    padding: 16px 24px;
    border-bottom: 1px solid #333;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #181818;
}

.form-builder-v2-header h2 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 500;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 12px;
}

.form-builder-v2-close {
    background: transparent;
    border: 1px solid #444;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #e0e0e0;
    font-size: 1rem;
    transition: all 0.2s ease;
}

.form-builder-v2-close:hover {
    background: #ff4444;
    border-color: #ff4444;
    color: #ffffff;
}

/* ===== MAIN CONTENT ===== */
.form-builder-v2-content {
    flex: 1;
    display: grid;
    grid-template-columns: 240px 1fr 280px;
    gap: 0;
    overflow: hidden;
    background: #1f1f1f;
}

/* ===== LEFT SIDEBAR - PANEL PALETTE ===== */
.form-builder-v2-sidebar {
    background: #181818;
    border-right: 1px solid #333;
    padding: 20px 16px;
    overflow-y: auto;
}

.form-builder-v2-sidebar h3 {
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-palette {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.panel-palette-item {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    padding: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
    color: #e0e0e0;
    font-size: 0.9rem;
    width: 100%;
    text-align: left;
}

.panel-palette-item:hover {
    background: #3a3a3a;
    border-color: #4a90e2;
    transform: translateX(4px);
}

.panel-palette-item i {
    font-size: 1.1rem;
    color: #4a90e2;
    width: 20px;
    text-align: center;
}

/* ===== CENTER - GRID CANVAS ===== */
.form-builder-v2-canvas-wrapper {
    display: flex;
    flex-direction: column;
    background: #1a1a1a;
    overflow: hidden;
}

.canvas-toolbar {
    padding: 12px 20px;
    border-bottom: 1px solid #333;
    background: #1f1f1f;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.form-title-input-v2 {
    flex: 1;
    padding: 8px 12px;
    font-size: 1.1rem;
    font-weight: 500;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    background: #2a2a2a;
    color: #ffffff;
    transition: border-color 0.2s ease;
}

.form-title-input-v2:focus {
    outline: none;
    border-color: #4a90e2;
}

.toolbar-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

.toolbar-btn {
    background: #2a2a2a;
    border: 1px solid #3a3a3a;
    width: 32px;
    height: 32px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #9e9e9e;
    transition: all 0.2s ease;
}

.toolbar-btn:hover {
    background: #3a3a3a;
    border-color: #4a90e2;
    color: #4a90e2;
}

.grid-info {
    font-size: 0.85rem;
    color: #9e9e9e;
    padding: 6px 12px;
    background: #2a2a2a;
    border-radius: 4px;
    border: 1px solid #3a3a3a;
}

/* ===== GRID CANVAS ===== */
.grid-canvas {
    flex: 1;
    position: relative;
    overflow: auto;
    background: #1a1a1a;
    min-height: 600px;
}

.grid-background {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
    z-index: 1;
}

.grid-line-vertical {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 1px;
    background: rgba(255, 255, 255, 0.05);
}

.grid-panels {
    position: relative;
    min-height: 100%;
    z-index: 2;
}

/* ===== GRID PANELS ===== */
.grid-panel {
    position: absolute;
    background: #2a2a2a;
    border: 2px solid #3a3a3a;
    border-radius: 4px;
    cursor: pointer;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.grid-panel:hover {
    border-color: #4a90e2;
}

.grid-panel.selected {
    border-color: #4a90e2;
    box-shadow: 0 0 0 3px rgba(74, 144, 226, 0.2);
}

/* Panel Drag Handle */
.panel-drag-handle {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    background: rgba(0, 0, 0, 0.3);
    color: #9e9e9e;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.grid-panel:hover .panel-drag-handle {
    opacity: 1;
}

.panel-drag-handle:active {
    cursor: grabbing;
}

/* Panel Content */
.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px;
    text-align: center;
    gap: 8px;
}

.panel-icon {
    width: 48px;
    height: 48px;
    border-radius: 8px;
    background: #3a3a3a;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #4a90e2;
    font-size: 1.5rem;
}

.panel-label {
    font-size: 1rem;
    font-weight: 500;
    color: #ffffff;
    word-break: break-word;
}

.panel-type {
    font-size: 0.8rem;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Panel Delete Button */
.panel-delete {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    background: rgba(255, 68, 68, 0.8);
    border: none;
    color: #ffffff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 11;
}

.grid-panel:hover .panel-delete {
    opacity: 1;
}

.panel-delete:hover {
    background: #ff4444;
}

/* Resize Handles */
.resize-handle {
    position: absolute;
    background: #4a90e2;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 12;
}

.grid-panel:hover .resize-handle {
    opacity: 1;
}

.resize-handle.resize-e {
    right: -3px;
    top: 0;
    bottom: 0;
    width: 6px;
    cursor: ew-resize;
}

.resize-handle.resize-s {
    left: 0;
    right: 0;
    bottom: -3px;
    height: 6px;
    cursor: ns-resize;
}

.resize-handle.resize-se {
    right: -3px;
    bottom: -3px;
    width: 12px;
    height: 12px;
    cursor: nwse-resize;
    border-radius: 0 0 4px 0;
}

/* ===== RIGHT SIDEBAR - PROPERTIES ===== */
.form-builder-v2-properties {
    background: #181818;
    border-left: 1px solid #333;
    padding: 20px 16px;
    overflow-y: auto;
}

.form-builder-v2-properties h3 {
    margin: 0 0 16px 0;
    font-size: 0.95rem;
    font-weight: 600;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.panel-properties-content {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.properties-empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    color: #666;
    text-align: center;
}

.properties-empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    opacity: 0.3;
}

.properties-empty-state p {
    font-size: 0.9rem;
    margin: 0;
}

.property-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.property-group label {
    font-size: 0.85rem;
    font-weight: 500;
    color: #9e9e9e;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.property-group input[type="text"],
.property-group input[type="number"],
.property-group textarea {
    padding: 8px 10px;
    border: 1px solid #3a3a3a;
    border-radius: 4px;
    font-size: 0.9rem;
    background: #2a2a2a;
    color: #e0e0e0;
    transition: border-color 0.2s ease;
    font-family: inherit;
}

.property-group input:focus,
.property-group textarea:focus {
    outline: none;
    border-color: #4a90e2;
}

.property-group textarea {
    min-height: 80px;
    resize: vertical;
}

.grid-position-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 8px;
    border-radius: 4px;
    transition: background-color 0.2s ease;
}

.checkbox-label:hover {
    background-color: #2a2a2a;
}

.checkbox-label input[type="checkbox"] {
    width: 16px;
    height: 16px;
    cursor: pointer;
    accent-color: #4a90e2;
}

.checkbox-label span {
    font-size: 0.9rem;
    color: #e0e0e0;
}

.property-info {
    padding: 10px;
    background: rgba(74, 144, 226, 0.1);
    border-left: 3px solid #4a90e2;
    border-radius: 4px;
    margin-top: 8px;
}

.property-info p {
    margin: 0;
    font-size: 0.8rem;
    color: #9e9e9e;
    display: flex;
    align-items: center;
    gap: 8px;
}

.property-info i {
    color: #4a90e2;
}

/* ===== FOOTER ===== */
.form-builder-v2-footer {
    padding: 16px 24px;
    border-top: 1px solid #333;
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    background: #181818;
}

.btn-primary,
.btn-secondary {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s ease;
}

.btn-primary {
    background: #4a90e2;
    color: #ffffff;
    border: 1px solid #4a90e2;
}

.btn-primary:hover {
    background: #3a7bc8;
    box-shadow: 0 4px 12px rgba(74, 144, 226, 0.3);
}

.btn-secondary {
    background: transparent;
    color: #9e9e9e;
    border: 1px solid #3a3a3a;
}

.btn-secondary:hover {
    background: #2a2a2a;
    border-color: #4a4a4a;
    color: #e0e0e0;
}

/* ===== ANIMATIONS ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== SCROLLBAR STYLING ===== */
.form-builder-v2-sidebar::-webkit-scrollbar,
.form-builder-v2-properties::-webkit-scrollbar,
.grid-canvas::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

.form-builder-v2-sidebar::-webkit-scrollbar-track,
.form-builder-v2-properties::-webkit-scrollbar-track,
.grid-canvas::-webkit-scrollbar-track {
    background: #1a1a1a;
}

.form-builder-v2-sidebar::-webkit-scrollbar-thumb,
.form-builder-v2-properties::-webkit-scrollbar-thumb,
.grid-canvas::-webkit-scrollbar-thumb {
    background: #3a3a3a;
    border-radius: 4px;
}

.form-builder-v2-sidebar::-webkit-scrollbar-thumb:hover,
.form-builder-v2-properties::-webkit-scrollbar-thumb:hover,
.grid-canvas::-webkit-scrollbar-thumb:hover {
    background: #4a4a4a;
}

/* ===== RESPONSIVE DESIGN ===== */
@media (max-width: 1200px) {
    .form-builder-v2-content {
        grid-template-columns: 200px 1fr 260px;
    }
}

@media (max-width: 1024px) {
    .form-builder-v2-container {
        width: 98vw;
        height: 95vh;
    }

    .form-builder-v2-content {
        grid-template-columns: 180px 1fr 240px;
    }
}

/* ===== ACCESSIBILITY ===== */
.form-builder-v2-close:focus,
.panel-palette-item:focus,
.grid-panel:focus,
.btn-primary:focus,
.btn-secondary:focus {
    outline: 2px solid #4a90e2;
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .form-builder-v2-modal,
    .form-builder-v2-container,
    .panel-palette-item,
    .grid-panel,
    .btn-primary,
    .btn-secondary {
        animation: none;
        transition: none;
    }
}

/* ===== CONFIRMATION MODAL ===== */
.form-builder-v2-confirm-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 20000;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.2s ease;
}

.confirm-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
}

.confirm-modal-content {
    position: relative;
    background: #1f1f1f;
    border-radius: 12px;
    padding: 32px;
    max-width: 440px;
    width: 90%;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    animation: slideUp 0.3s ease;
    text-align: center;
}

.confirm-modal-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 20px;
    border-radius: 50%;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff4444 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 1.5s ease-in-out infinite;
}

.confirm-modal-icon i {
    font-size: 2rem;
    color: #ffffff;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(255, 68, 68, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(255, 68, 68, 0);
    }
}

.confirm-modal-title {
    margin: 0 0 12px 0;
    font-size: 1.5rem;
    font-weight: 600;
    color: #ffffff;
}

.confirm-modal-message {
    margin: 0 0 28px 0;
    font-size: 1rem;
    line-height: 1.6;
    color: #9e9e9e;
}

.confirm-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.confirm-btn-cancel,
.confirm-btn-confirm {
    padding: 12px 32px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.confirm-btn-cancel {
    background: #2a2a2a;
    color: #e0e0e0;
    border: 1px solid #3a3a3a;
}

.confirm-btn-cancel:hover {
    background: #3a3a3a;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.confirm-btn-confirm {
    background: linear-gradient(135deg, #ff6b6b 0%, #ff4444 100%);
    color: #ffffff;
    border: 1px solid #ff4444;
}

.confirm-btn-confirm:hover {
    background: linear-gradient(135deg, #ff5555 0%, #ff3333 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 68, 68, 0.5);
}
