/* UI/UX Design - Premium Glassmorphism Dark Mode */

:root {
    /* Modern Slate - Balanced Mode */
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-elevated: #f1f5f9;
    --border: #e2e8f0;
    --border-subtle: #f1f5f9;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #94a3b8;

    /* Accent Colors (Blue - Trust) */
    --color-primary: #2563eb;
    --color-primary-hover: #1d4ed8;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-error: #dc2626;

    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 16px;
    --space-4: 24px;
    --space-5: 32px;
    --space-6: 48px;

    /* Radius */
    --radius-sm: 4px;
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --radius-full: 9999px;

    /* Glassmorphism - Balanced */
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: 1px solid rgba(15, 23, 42, 0.08);
    --glass-blur: blur(12px);
    --glass-shadow: 0 8px 32px 0 rgba(15, 23, 42, 0.05);

    /* Animation */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --duration-normal: 250ms;
}

/* CSS Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
}

* {
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--background);
    /* Soft cyan/blue decorative gradients */
    background-image: radial-gradient(circle at 15% 50%, rgba(37, 99, 235, 0.05), transparent 25%), radial-gradient(circle at 85% 30%, rgba(56, 189, 248, 0.05), transparent 25%);
    background-attachment: fixed;
    color: var(--text-primary);
    font-family:
        'Inter',
        system-ui,
        -apple-system,
        sans-serif;
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

/* SweetAlert2 Fixes: Ensure it centers in viewport */
.swal2-container {
    z-index: 10000 !important;
}

body.swal2-shown:not(.swal2-no-backdrop):not(.swal2-toast-shown) {
    overflow: hidden !important;
}

.swal2-popup {
    border-radius: 20px !important;
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Typography */
h1,
h2,
h3,
h4 {
    color: var(--text-primary);
    font-weight: 600;
    line-height: 1.2;
    margin-bottom: var(--space-3);
}

h1 {
    font-size: 2.5rem;
    letter-spacing: -0.02em;
}

h3 {
    font-size: 1.5rem;
}

p {
    color: var(--text-secondary);
    margin-bottom: var(--space-3);
}

/* Layout */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: var(--space-5);
}

.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4) var(--space-5);
    margin-bottom: var(--space-6);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(12px);
    border-bottom: var(--glass-border);
    border-radius: var(--radius-lg);
    position: sticky;
    top: var(--space-4);
    z-index: 100;
    box-shadow: 0 4px 20px -5px rgba(15, 23, 42, 0.05);
}

.logo-container {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.logo-img {
    height: 50px;
    width: auto;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.1));
}

.logo h1 {
    font-size: 1.5rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--space-2);
    background: linear-gradient(135deg, #0f172a 0%, #334155 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo p {
    font-size: 0.875rem;
    margin: 0;
    color: var(--text-muted);
}

.user-info {
    color: var(--text-secondary);
    font-weight: 500;
    background: var(--surface-elevated);
    padding: var(--space-2) var(--space-3);
    border-radius: var(--radius-full);
    border: 1px solid var(--border);
}

/* Glass Cards */
.glass-card {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    border: var(--glass-border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    transition: all var(--duration-normal) var(--ease-out);
    box-shadow: var(--glass-shadow);
}

/* Dashboard Layout & Process Groups */
.dashboard-home-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-4);
}

@media (min-width: 1024px) {
    .dashboard-home-layout {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: var(--space-6);
        align-items: start;
    }

    .full-width {
        grid-column: span 2;
    }
}

/* Module Layouts (Visitors, etc) */
.sidebar-layout {
    display: flex;
    flex-direction: column;
    gap: var(--space-5);
}

@media (min-width: 1024px) {
    .sidebar-layout {
        display: grid;
        grid-template-columns: 1.4fr 1fr;
        align-items: start;
    }
}

.group-title {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    opacity: 0.8;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: var(--space-4);
    width: 100%;
}

/* Action Cards - Premium Modern Look */
.action-card {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-4);
    display: flex;
    align-items: center;
    gap: var(--space-4);
    text-decoration: none;
    transition: all 0.3s var(--ease-out);
    position: relative;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.02);
}

.action-card:hover {
    transform: translateY(-4px);
    border-color: var(--color-primary);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.08);
}

.action-card::after {
    content: '\f105';
    /* fa-chevron-right */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    right: 20px;
    opacity: 0;
    transition: all 0.3s;
    color: var(--color-primary);
}

.action-card:hover::after {
    opacity: 1;
    right: 24px;
}

.card-icon {
    font-size: 1.75rem;
    width: 56px;
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    flex-shrink: 0;
    transition: all 0.3s;
}

.action-card:hover .card-icon {
    background: rgba(37, 99, 235, 0.1);
    transform: scale(1.1);
}

.card-info {
    padding-right: var(--space-4);
}

.card-info h3 {
    font-size: 1.05rem;
    margin-bottom: 2px;
    color: var(--text-primary);
}

.card-info p {
    font-size: 0.85rem;
    margin: 0;
    color: var(--text-muted);
    line-height: 1.4;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: 10px 20px;
    font-size: 0.95rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: none;
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    color: white;
}

.btn-primary {
    background: var(--color-primary);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.2);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(37, 99, 235, 0.3);
}

.btn-danger {
    background: var(--color-error);
}

.btn-danger:hover {
    background: #b91c1c;
}

.btn-success {
    background: var(--color-success);
}

.btn-success:hover {
    background: #15803d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.85rem;
}

/* Forms */
.form-group {
    margin-bottom: var(--space-4);
}

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-2);
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-size: 1rem;
    transition: all var(--duration-normal) var(--ease-out);
}

.form-control:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: var(--space-4);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: var(--radius-full);
}

.badge-active {
    background: rgba(22, 163, 74, 0.15);
    color: #16a34a;
    border: 1px solid rgba(22, 163, 74, 0.2);
}

.badge-warning {
    background: rgba(217, 119, 6, 0.15);
    color: #d97706;
    border: 1px solid rgba(217, 119, 6, 0.2);
}

.badge-inactive {
    background: var(--surface-elevated);
    color: var(--text-muted);
}

/* List Items */
.list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--duration-normal) var(--ease-out);
}

.list-item:hover {
    background: rgba(255, 255, 255, 0.02);
}

.list-item:last-child {
    border-bottom: none;
}

.list-item-content h4 {
    margin-bottom: 4px;
    font-size: 1rem;
}

.list-item-content p {
    font-size: 0.875rem;
    margin: 0;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Search Results / Autocomplete */
.search-item {
    padding: var(--space-3);
    cursor: pointer;
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--duration-normal) var(--ease-out);
}

.search-item:hover {
    background: var(--surface-elevated);
}

.search-item:last-child {
    border-bottom: none;
}

.search-item strong {
    color: var(--text-primary);
    display: block;
}

.search-item small {
    color: var(--text-muted);
}

/* Animations */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fadeIn 0.6s var(--ease-out) forwards;
}

/* Utilities */
.text-primary {
    color: var(--color-primary) !important;
}

.text-success {
    color: var(--color-success) !important;
}

.text-secondary {
    color: var(--text-secondary) !important;
}

/* Modals - Fixed Overlays */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(8px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    padding: var(--space-4);
}

.modal-overlay.active {
    display: flex;
    animation: fadeInModal 0.3s var(--ease-out);
}

.modal-content {
    background: var(--surface);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: var(--space-5);
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.25);
    position: relative;
    color: var(--text-primary);
    margin: auto;
    /* Extra insurance for centering */
}

@keyframes fadeInModal {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Scroll lock for manual modals */
body.modal-open {
    overflow: hidden !important;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
    border-bottom: 1px solid var(--border-subtle);
    padding-bottom: var(--space-3);
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-muted);
    cursor: pointer;
    transition: color 0.2s;
}

.btn-close:hover {
    color: var(--color-error);
}

.history-table th {
    background: var(--surface-elevated);
    color: var(--text-secondary);
    border-bottom: 1px solid var(--border);
}

.history-table td {
    border-bottom: 1px solid var(--border-subtle);
    color: var(--text-primary);
}

.history-table tr:hover {
    background: var(--surface-elevated);
}

/* Phase & Accordion Components */
.phase-header {
    background: var(--surface-elevated);
    padding: var(--space-4);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    transition: all var(--duration-normal) var(--ease-out);
}

.phase-header.active {
    background: rgba(37, 99, 235, 0.1);
    border-color: var(--color-primary);
}

.phase-header h3 {
    margin-bottom: 0;
    font-size: 1.1rem;
}

.phase-content {
    display: none;
    padding: var(--space-5);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}

.phase-content.show {
    display: block;
    animation: fadeIn 0.4s var(--ease-out);
}

/* Staff & Tags */
.staff-tags {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin-top: var(--space-2);
    min-height: 40px;
    padding: var(--space-2);
    background: var(--surface-elevated);
    border-radius: var(--radius-md);
    border: 1px dashed var(--border);
}

.staff-chip {
    background: var(--color-primary);
    color: white;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    gap: var(--space-2);
    font-size: 0.85rem;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.2);
}

.staff-chip i {
    cursor: pointer;
    font-size: 0.75rem;
    opacity: 0.8;
}

.staff-chip i:hover {
    opacity: 1;
}

.staff-section {
    background: var(--surface);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
    margin-bottom: var(--space-4);
}

/* Weight Row Layout */
.weight-row {
    display: flex;
    gap: var(--space-3);
    align-items: flex-end;
    margin-bottom: var(--space-3);
}

/* Page Transitions */
.page-fade-in {
    animation: fadeIn 0.5s var(--ease-out) forwards;
}

/* Responsive Customizations */
@media (max-width: 768px) {
    .phase-content {
        padding: var(--space-4);
    }
}
