/* Premium Modal System - 2025 Redesign */
:root {
    --modal-bg: #1e2128;
    --modal-overlay-bg: rgba(0, 0, 0, 0.85);
    --modal-border: #3a3f4a;
    --primary-color: #6366f1;
    /* Indigo 500 */
    --primary-hover: #4f46e5;
    /* Indigo 600 */
    --text-primary: #f3f4f6;
    --text-secondary: #9ca3af;
    --input-bg: #282c34;
    --input-border: #404550;
    --radius-lg: 16px;
    --radius-md: 8px;
    --shadow-xl: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
}



/* Overlay with Blur Effect */
.modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: var(--modal-overlay-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}


.modal-overlay.show {
    display: flex !important;
    opacity: 1;
}

/* Modal Container */
.modal-content,
.modal {
    background: var(--modal-bg);
    border: 1px solid var(--modal-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 720px;
    /* Wider for better symmetry */
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: var(--shadow-xl);
    transform: scale(0.95) translateY(10px);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
    margin: auto;
}

.modal-overlay.show .modal-content,
.modal-overlay.show .modal {
    transform: scale(1) translateY(0);
}

/* Header */
.modal-header {
    padding: 24px 32px;
    border-bottom: 1px solid var(--modal-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.02);
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 20px;
    font-weight: 600;
    letter-spacing: -0.025em;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: var(--primary-color);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 24px;
    cursor: pointer;
    padding: 4px;
    border-radius: 50%;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* Body */
.modal-body {
    padding: 32px;
    overflow-y: auto;
    color: var(--text-secondary);
}

/* Grid System for Forms */
.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 32px;
    /* Increased from 24px */
    margin-bottom: 32px;
    /* Increased from 24px */
}

.form-column {
    display: flex;
    flex-direction: column;
    gap: 24px;
    /* Increased from 20px */
}

/* Form Elements */
.form-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
    /* Increased from 8px */
    margin-bottom: 0;
    /* Handled by gap */
}

.form-group label {
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 500;
    margin-left: 2px;
}

.modal input[type="text"],
.modal input[type="email"],
.modal input[type="number"],
.modal input[type="password"],
.modal input[type="date"],
.modal select,
.modal textarea {
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    padding: 0 16px;
    height: 48px;
    /* Taller inputs */
    color: var(--text-primary);
    font-size: 14px;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.modal textarea {
    height: auto;
    padding: 16px;
    resize: vertical;
    min-height: 100px;
}

.modal input:focus,
.modal select:focus,
.modal textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
    background: #272a30;
}

.modal input::placeholder,
.modal textarea::placeholder {
    color: #52525b;
}

/* Custom Checkbox */
.checkbox-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    height: 48px;
    box-sizing: border-box;
}

.checkbox-container:hover {
    border-color: #4b5563;
}

.checkbox-container input[type="checkbox"] {
    width: 20px;
    height: 20px;
    accent-color: var(--primary-color);
    margin: 0;
}

.checkbox-text {
    font-size: 14px;
    color: var(--text-primary);
    font-weight: 500;
}

/* Sections (Cosmetics, Photos) */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--modal-border);
}

.section-header h4,
.photos-header h4,
.archive-header h4 {
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

.section-description {
    font-size: 12px;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

/* Quick Add Section */
.quick-add-section {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--modal-border);
    border-radius: var(--radius-md);
    padding: 20px;
    margin-bottom: 24px;
}

.quick-add-section .section-title {
    margin: 0 0 16px 0;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.quick-add-section .section-title i {
    color: #fbbf24;
    /* Amber 400 */
}

.quick-buttons {
    display: flex !important;
    flex-direction: row !important;
    gap: 12px !important;
    margin-bottom: 20px;
    flex-wrap: nowrap !important;
    /* Force single line */
    width: 100% !important;
}

.quick-buttons .btn {
    flex: 1 !important;
    height: 40px;
    font-size: 13px;
    white-space: nowrap !important;
}

.btn-success {
    background: #10b981;
    color: white;
    border: none;
}

.btn-success:hover {
    background: #059669;
}

.btn-warning {
    background: #f59e0b;
    color: white;
    border: none;
}

.btn-warning:hover {
    background: #d97706;
}

.btn-info {
    background: #3b82f6;
    color: white;
    border: none;
}

.btn-info:hover {
    background: #2563eb;
}

/* ... colors ... */

.bulk-section {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    gap: 12px !important;
    padding-top: 16px;
    border-top: 1px solid var(--modal-border);
    flex-wrap: nowrap !important;
    /* Force single line */
    width: 100% !important;
}

.bulk-section label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    white-space: nowrap;
}

.bulk-section select {
    width: auto !important;
    flex: 1 !important;
    height: 36px;
    font-size: 13px;
}

.bulk-section .btn {
    height: 36px;
    padding: 0 16px;
    white-space: nowrap;
}

.quick-add-info {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Photo Upload Areas */
.profile-photos-grid,
.archive-photos-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.profile-slot {
    aspect-ratio: 1;
    position: relative;
    border-radius: var(--radius-md);
    overflow: hidden;
    background: var(--input-bg);
    border: 1px solid var(--input-border);
}

.photo-upload-area {
    aspect-ratio: 1;
    background: var(--input-bg);
    border: 2px dashed var(--input-border);
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
    height: 100%;
    /* Ensure it fills the slot if nested */
    width: 100%;
}

/* Remove border from upload area if inside a slot, as slot has border */
.profile-slot .photo-upload-area {
    border: none;
    background: transparent;
}

.photo-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    color: var(--text-secondary);
    text-align: center;
}

.upload-placeholder i {
    font-size: 24px;
    margin-bottom: 4px;
}

.upload-placeholder span {
    font-size: 13px;
    font-weight: 500;
}

.upload-placeholder small {
    font-size: 11px;
    opacity: 0.7;
}

/* Footer & Actions */
.form-actions {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    /* Centered buttons */
    gap: 16px !important;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--modal-border);
    width: 100% !important;
}

.form-actions .btn {
    min-width: 140px;
    /* Ensure substantial width */
    width: auto !important;
}

.btn {
    height: 44px;
    padding: 0 24px;
    border-radius: var(--radius-md);
    font-size: 14px;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.3);
}

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 8px -1px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: transparent;
    border: 1px solid var(--input-border);
    color: var(--text-primary);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.05);
    border-color: #4b5563;
}

/* Scrollbar */
.modal-body::-webkit-scrollbar {
    width: 6px;
}

.modal-body::-webkit-scrollbar-track {
    background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
    background: #3f3f46;
    border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
    background: #52525b;
}

/* Mobile Responsive */
@media (max-width: 640px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .modal-content {
        width: 95%;
        max-height: 95vh;
    }

    .profile-photos-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

/* Photo Preview & Badges */
.photo-preview {
    width: 100%;
    height: 100%;
    position: relative;
}

.photo-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.photo-badge {
    position: absolute;
    top: 8px;
    left: 8px;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}

.photo-badge.main {
    background: var(--primary-color);
}

/* Robust Grid Fixes */
#profile-photos-container,
#archive-photos-container {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr) !important;
    gap: 16px !important;
    width: 100% !important;
}

/* Ensure slots have dimension */
.profile-slot,
.archive-photo-item {
    aspect-ratio: 1;
    position: relative;
    width: 100%;
    display: block;
}

/* Overlay Visibility Fixes */
.photo-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 100;
    /* High z-index */
    pointer-events: none;
    /* Prevent clicks when hidden */
}

.photo-upload-area:hover .photo-overlay,
.photo-preview:hover .photo-overlay,
.profile-slot:hover .photo-overlay,
.archive-photo-item:hover .photo-overlay {
    opacity: 1 !important;
    pointer-events: auto !important;
    /* Enable clicks when shown */
}

.photo-overlay .btn {
    width: 36px;
    height: 36px;
    padding: 0;
    border-radius: 50%;
    pointer-events: auto;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}
