/* Base Theme (Dark Mode Default for code, but user prefers Light initially or togglable) */
:root {
    /* Dark Mode variables */
    --bg-main: #0B0F19;
    --bg-panel: #1A1F2C;
    --bg-input: #0B0F19;
    --border-color: #2A303C;
    --text-main: #F8FAFC;
    --text-muted: #94A3B8;
    
    --primary: #3B82F6;
    --primary-hover: #2563EB;
    --danger: #EF4444;
    --success: #10B981;
    --warning: #F59E0B;
    --accent: #8B5CF6;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.3);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.4);
}

/* Light Mode overrides */
.light-mode {
    --bg-main: #F8FAFC;
    --bg-panel: #FFFFFF;
    --bg-input: #FFFFFF;
    --border-color: #E2E8F0;
    --text-main: #0F172A;
    --text-muted: #64748B;
    
    --primary: #2563EB;
    --primary-hover: #1D4ED8;
    
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Clean Panels */
.panel {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: var(--shadow-sm);
    transition: background-color 0.3s ease, border-color 0.3s ease;
}

/* Utility classes */
.hidden { display: none !important; }
.error-message { color: var(--danger); font-size: 0.875rem; margin-top: 0.5rem; }

/* Buttons */
.btn-primary, .btn-outline {
    display: inline-flex; align-items: center; justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem 1.25rem;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: var(--shadow-sm);
}
.btn-primary:hover { background: var(--primary-hover); box-shadow: var(--shadow-md); }
.btn-primary:disabled { opacity: 0.7; cursor: not-allowed; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-main);
}
.btn-outline:hover { background: var(--border-color); }

.btn-icon {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 6px;
    transition: color 0.2s, background 0.2s;
    display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text-main); background: var(--border-color); }

/* Form Elements */
.input-group { margin-bottom: 1rem; display: flex; flex-direction: column; gap: 0.3rem; }
.input-group.span-2 { grid-column: span 2; }
label { font-size: 0.875rem; font-weight: 500; color: var(--text-muted); }
input, select, textarea {
    width: 100%;
    padding: 0.625rem 0.875rem;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color 0.2s, box-shadow 0.2s, background-color 0.3s ease;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* Loader */
.loader {
    width: 16px; height: 16px;
    border: 2px solid transparent;
    border-bottom-color: currentColor;
    border-radius: 50%;
    display: inline-block;
    animation: rotation 1s linear infinite;
}
@keyframes rotation { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }

/* Login Screen */
.login-container {
    position: fixed; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background-color: var(--bg-main);
}
.login-box {
    background: var(--bg-panel);
    border: 1px solid var(--border-color);
    padding: 3rem;
    border-radius: 12px;
    width: 100%; max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}
.login-box .logo { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin-bottom: 1rem; letter-spacing: 1px; }
.login-box h2 { font-size: 1.75rem; font-weight: 600; margin-bottom: 0.5rem; color: var(--text-main); }
.login-box p { color: var(--text-muted); margin-bottom: 2rem; font-size: 0.875rem; }
.login-box form { text-align: left; }
.login-box button { width: 100%; margin-top: 1rem; padding: 0.75rem; }

/* Dashboard Layout */
.dashboard-layout { display: flex; height: 100vh; }

.sidebar {
    width: 260px;
    display: flex; flex-direction: column;
    background: var(--bg-panel);
    border-right: 1px solid var(--border-color);
}
.sidebar .logo {
    padding: 1.5rem; font-size: 1.25rem; font-weight: 700; color: var(--primary);
    border-bottom: 1px solid var(--border-color);
    letter-spacing: 1px;
}
.nav-menu { flex: 1; padding: 1.5rem 1rem; display: flex; flex-direction: column; gap: 0.5rem; }
.nav-item {
    display: flex; align-items: center; gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted); text-decoration: none;
    border-radius: 6px; transition: all 0.2s;
    font-weight: 500; font-size: 0.875rem;
}
.nav-item:hover { background: var(--bg-main); color: var(--text-main); }
.nav-item.active { background: rgba(59, 130, 246, 0.1); color: var(--primary); }

.user-info {
    padding: 1.5rem; border-top: 1px solid var(--border-color);
    display: flex; align-items: center; gap: 0.75rem;
}
.avatar {
    width: 36px; height: 36px; border-radius: 50%;
    background: rgba(59, 130, 246, 0.1); color: var(--primary);
    display: flex; align-items: center; justify-content: center;
}
.user-info .details { flex: 1; display: flex; flex-direction: column; }
.user-info .details span { font-size: 0.875rem; font-weight: 600; color: var(--text-main); }
.user-info .role { font-size: 0.75rem; color: var(--text-muted); font-weight: 400; }

.main-content { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.topbar {
    padding: 1.5rem 2.5rem;
    display: flex; justify-content: space-between; align-items: center;
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-panel);
}
.topbar h1 { font-size: 1.25rem; font-weight: 600; color: var(--text-main); }
.topbar .actions { display: flex; align-items: center; gap: 1rem; }

.view-section { padding: 2rem 2.5rem; flex: 1; display: flex; flex-direction: column; gap: 1.5rem; overflow-y: auto; }

/* Filters & Table */
.filters {
    padding: 1rem 1.5rem; display: flex; gap: 1rem; align-items: center;
}
.search-input { flex: 1; max-width: 300px; }
.filters select { width: auto; min-width: 150px; }

.table-container { flex: 1; overflow: auto; position: relative; }
table { width: 100%; border-collapse: collapse; text-align: left; }
th, td { padding: 1rem 1.5rem; border-bottom: 1px solid var(--border-color); white-space: nowrap; font-size: 0.875rem; }
th { text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); font-weight: 600; font-size: 0.75rem; position: sticky; top: 0; background: var(--bg-panel); z-index: 10; border-bottom: 2px solid var(--border-color); }
tbody tr:hover { background: var(--bg-main); }
td { color: var(--text-main); }

.badge {
    padding: 0.25rem 0.6rem; border-radius: 4px; font-size: 0.75rem; font-weight: 600;
}
.badge.status-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge.status-inport { background: rgba(59, 130, 246, 0.1); color: var(--primary); border: 1px solid rgba(59, 130, 246, 0.2); }
.badge.status-cleared { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); }
.badge.type-import { background: rgba(139, 92, 246, 0.1); color: var(--accent); border: 1px solid rgba(139, 92, 246, 0.2); }
.badge.type-export { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }

.pagination { display: flex; justify-content: space-between; align-items: center; font-size: 0.875rem; color: var(--text-muted); }

/* Modal */
.modal { position: fixed; inset: 0; z-index: 100; display: flex; align-items: center; justify-content: center; }
.modal-backdrop { position: absolute; inset: 0; background: rgba(0,0,0,0.4); backdrop-filter: blur(2px); }
.modal-content {
    position: relative; width: 100%; max-width: 800px; max-height: 90vh;
    display: flex; flex-direction: column;
    box-shadow: var(--shadow-lg);
}
.modal-header { padding: 1.5rem 2rem; border-bottom: 1px solid var(--border-color); display: flex; justify-content: space-between; align-items: center; }
.modal-header h2 { font-size: 1.25rem; font-weight: 600; }
.modal-body { padding: 2rem; overflow-y: auto; }
.form-section { margin-bottom: 2.5rem; }
.form-section h3 { font-size: 0.875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: var(--text-muted); margin-bottom: 1rem; padding-bottom: 0.5rem; border-bottom: 1px solid var(--border-color); }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1.25rem; }
.modal-actions { padding-top: 1.5rem; border-top: 1px solid var(--border-color); display: flex; justify-content: flex-end; gap: 1rem; }

/* ---------------------------------------------------
   Mobile & Tablet Responsiveness
   --------------------------------------------------- */
@media (max-width: 768px) {
    /* Login Box */
    .login-box {
        padding: 2rem 1.5rem;
        margin: 1rem;
    }

    /* Topbar & Header */
    .topbar {
        padding: 1rem;
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    .topbar .actions {
        width: 100%;
        justify-content: space-between;
    }

    /* Layout & Sidebar (Bottom Nav) */
    .dashboard-layout {
        flex-direction: column;
    }
    .main-content {
        /* Leave space for bottom nav */
        padding-bottom: 70px;
    }
    .sidebar {
        width: 100%;
        height: 70px;
        flex-direction: row;
        position: fixed;
        bottom: 0;
        left: 0;
        border-right: none;
        border-top: 1px solid var(--border-color);
        z-index: 50;
        align-items: center;
        justify-content: space-between;
        padding: 0 1rem;
    }
    .sidebar .logo {
        display: none; /* Hide logo on mobile bottom nav */
    }
    .nav-menu {
        flex-direction: row;
        padding: 0;
        gap: 1rem;
    }
    .nav-item {
        flex-direction: column;
        padding: 0.5rem;
        font-size: 0.7rem;
        gap: 0.2rem;
    }
    .nav-item svg {
        width: 24px;
        height: 24px;
    }
    .user-info {
        border-top: none;
        padding: 0;
    }
    .user-info .details {
        display: none; /* Hide user name and role */
    }

    /* Filters */
    .filters {
        flex-direction: column;
        align-items: stretch;
    }
    .search-input {
        max-width: 100%;
    }

    /* View Section */
    .view-section {
        padding: 1rem;
    }

    /* Modals */
    .modal-content {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
    }
    .form-grid {
        grid-template-columns: 1fr; /* Stack form inputs */
    }
    
    /* Table scrolling */
    .table-container {
        -webkit-overflow-scrolling: touch;
    }
}
