/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --brand-blue: #1E40AF;
    --brand-blue-light: #3B82F6;
    --brand-blue-dark: #1E3A8A;
    --brand-red: #DC2626;
    --brand-red-light: #EF4444;
    
    --gray-50: #F9FAFB;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-600: #4B5563;
    --gray-700: #374151;
    --gray-800: #1F2937;
    --gray-900: #111827;
    
    --success: #10B981;
    --warning: #F59E0B;
    --error: #EF4444;
    --info: #3B82F6;
    
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #F9FAFB 0%, #E5E7EB 100%);
    color: var(--gray-900);
    line-height: 1.6;
    min-height: 100vh;
}

/* Loading Screen */
.loading-screen {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #0A1F44 0%, #1E3A8A 25%, #1E40AF 50%, #2563EB 75%, #1E3A8A 100%);
    background-size: 400% 400%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: gradientShift 8s ease infinite;
    transition: opacity 0.5s ease-out;
}

@keyframes gradientShift {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

.loading-content {
    text-align: center;
    animation: floatIn 1s ease-out;
    padding: 3rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 2rem;
    backdrop-filter: blur(20px);
    border: 2px solid rgba(255, 255, 255, 0.1);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    position: relative;
    overflow: hidden;
}

.loading-content::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.03),
        transparent
    );
    animation: shimmer 3s infinite;
}

@keyframes shimmer {
    0% { transform: translateX(-100%) translateY(-100%) rotate(45deg); }
    100% { transform: translateX(100%) translateY(100%) rotate(45deg); }
}

@keyframes floatIn {
    from {
        opacity: 0;
        transform: translateY(50px) scale(0.9);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.loading-logo {
    width: 180px;
    height: auto;
    margin-bottom: 2rem;
    filter: drop-shadow(0 15px 35px rgba(37, 99, 235, 0.6));
    animation: logoFloat 3s ease-in-out infinite, logoPulse 2s ease-in-out infinite;
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0px) rotate(0deg); }
    50% { transform: translateY(-15px) rotate(2deg); }
}

@keyframes logoPulse {
    0%, 100% { filter: drop-shadow(0 15px 35px rgba(37, 99, 235, 0.6)); }
    50% { filter: drop-shadow(0 20px 50px rgba(59, 130, 246, 0.9)); }
}

.loading-text {
    font-size: 1.5rem;
    font-weight: 700;
    color: white;
    margin-bottom: 2rem;
    letter-spacing: 2px;
    text-transform: uppercase;
    opacity: 0.95;
    text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    animation: textGlow 2s ease-in-out infinite;
}

@keyframes textGlow {
    0%, 100% { 
        text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5),
                     0 0 20px rgba(59, 130, 246, 0.3);
    }
    50% { 
        text-shadow: 0 4px 20px rgba(0, 0, 0, 0.5),
                     0 0 40px rgba(96, 165, 250, 0.6),
                     0 0 60px rgba(147, 197, 253, 0.4);
    }
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #3B82F6;
    border-right-color: #60A5FA;
    border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.265, 1.55) infinite;
    margin: 0 auto;
    box-shadow: 0 0 30px rgba(59, 130, 246, 0.4);
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Login Page */
.login-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: linear-gradient(135deg, #0A1F44 0%, #1E3A8A 25%, #1E40AF 50%, #2563EB 75%, #1E3A8A 100%);
    background-size: 400% 400%;
    animation: gradientShift 8s ease infinite;
}

.login-card {
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 420px;
    overflow: hidden;
    animation: slideUp 0.5s ease-out;
}

.login-header {
    text-align: center;
    padding: 3rem 2rem 2rem;
    background: linear-gradient(135deg, var(--gray-50) 0%, white 100%);
}

.login-logo {
    width: 150px;
    height: auto;
    margin: 0 auto 1.5rem;
}

.login-header h1 {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.login-header p {
    color: var(--gray-600);
    font-size: 0.95rem;
}

.login-form {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: 0.5rem;
}

.form-group input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 1rem;
    transition: all 0.2s;
    background: white;
}

.form-group input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.error-message {
    background: #FEE2E2;
    color: #991B1B;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--error);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 0.5rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: var(--brand-blue);
    color: white;
    width: 100%;
}

.btn-primary:hover:not(:disabled) {
    background: var(--brand-blue-dark);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: white;
    color: var(--gray-700);
    border: 2px solid var(--gray-200);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-50);
    border-color: var(--gray-300);
}

.btn-loader {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* Dashboard Header */
.dashboard-header {
    background: white;
    border-bottom: 1px solid var(--gray-200);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-logo {
    width: 120px;
    height: auto;
}

.header-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--gray-900);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 1rem;
    background: var(--gray-50);
    border-radius: 0.5rem;
}

.user-info span {
    font-weight: 600;
    color: var(--gray-700);
}

/* Dashboard Main */
.dashboard-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 2rem;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-blue {
    background: linear-gradient(135deg, #1E40AF 0%, #3B82F6 100%);
    color: white;
}

.stat-icon-orange {
    background: linear-gradient(135deg, #FED7AA 0%, #FDBA74 100%);
    color: #EA580C;
}

.stat-icon-purple {
    background: linear-gradient(135deg, #E9D5FF 0%, #D8B4FE 100%);
    color: #9333EA;
}

.stat-icon-green {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    color: var(--success);
}

.stat-content {
    flex: 1;
}

.stat-label {
    font-size: 0.875rem;
    color: var(--gray-600);
    margin-bottom: 0.25rem;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

/* Filters Section */
.filters-section {
    background: white;
    border-radius: 0.75rem;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    margin-bottom: 1.5rem;
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    align-items: center;
}

.filters-left {
    flex: 1;
    min-width: 250px;
}

.filters-right {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.search-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    transition: all 0.2s;
}

.search-input:focus {
    outline: none;
    border-color: var(--brand-blue);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.filter-select {
    padding: 0.75rem 1rem;
    border: 2px solid var(--gray-200);
    border-radius: 0.5rem;
    font-size: 0.95rem;
    background: white;
    cursor: pointer;
    transition: all 0.2s;
}

.filter-select:focus {
    outline: none;
    border-color: var(--brand-blue);
}

/* Table Container */
.table-container {
    background: white;
    border-radius: 0.75rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.loading-state, .empty-state {
    padding: 4rem 2rem;
    text-align: center;
}

.empty-state svg {
    color: var(--gray-300);
    margin-bottom: 1rem;
}

.empty-state h3 {
    font-size: 1.25rem;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.empty-state p {
    color: var(--gray-600);
}

/* Deliveries Table */
.deliveries-table {
    width: 100%;
    border-collapse: collapse;
}

.deliveries-table thead {
    background: var(--gray-50);
    border-bottom: 2px solid var(--gray-200);
}

.deliveries-table th {
    padding: 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--gray-700);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.deliveries-table tbody tr {
    border-bottom: 1px solid var(--gray-200);
    transition: background 0.2s;
}

.deliveries-table tbody tr:hover {
    background: var(--gray-50);
}

.deliveries-table td {
    padding: 1rem;
    font-size: 0.875rem;
    color: var(--gray-700);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.375rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-awaiting { background: #FEF3C7; color: #92400E; }
.status-transit { background: #DDD6FE; color: #5B21B6; }
.status-out { background: #1E40AF; color: white; font-weight: 700; }
.status-attempted { background: #FED7AA; color: #9A3412; }
.status-pending-otp { background: #FCE7F3; color: #831843; }
.status-delivered { background: #D1FAE5; color: #065F46; }

.btn-action {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 0.375rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-action-primary {
    background: var(--brand-blue);
    color: white;
}

.btn-action-primary:hover {
    background: var(--brand-blue-dark);
}

/* Modal */
.modal {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    animation: fadeIn 0.2s ease-out;
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 1rem;
    box-shadow: var(--shadow-xl);
    width: 100%;
    max-width: 800px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.3s ease-out;
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h2 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
}

.modal-close {
    width: 40px;
    height: 40px;
    border-radius: 0.5rem;
    border: none;
    background: var(--gray-100);
    color: var(--gray-600);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--gray-200);
    color: var(--gray-900);
}

.modal-body {
    padding: 2rem;
    overflow-y: auto;
}

/* Responsive */
@media (max-width: 768px) {
    .header-content {
        padding: 1rem;
    }
    
    .header-title {
        display: none;
    }
    
    .dashboard-main {
        padding: 1rem;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .filters-section {
        flex-direction: column;
    }
    
    .filters-left, .filters-right {
        width: 100%;
    }
    
    .table-container {
        overflow-x: auto;
    }
    
    .deliveries-table {
        min-width: 800px;
    }
}
