/* Admin & Dashboard Template - Custom Code Demo */
/* Built with Node.js + Supabase + Tailwind CSS + Chart.js */
/* Focus: Data Management, Analytics, Role-based Access */

/* Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Kanit', sans-serif;
    line-height: 1.6;
    color: #374151;
    background-color: #f9fafb;
}

/* Performance Optimizations */
img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Custom Font */
.font-kanit {
    font-family: 'Kanit', sans-serif;
}

/* Sidebar Animations */
.sidebar-enter {
    transform: translateX(-100%);
}

.sidebar-enter-active {
    transform: translateX(0);
    transition: transform 0.3s ease;
}

/* Navigation */
.nav-link {
    transition: all 0.2s ease;
}

.nav-link.active {
    background-color: #dbeafe;
    color: #2563eb;
    font-weight: 600;
}

/* Stats Cards */
.stats-card {
    transition: all 0.3s ease;
}

.stats-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
}

/* Table Styles */
.data-table {
    border-collapse: collapse;
    width: 100%;
}

.data-table th {
    background-color: #f9fafb;
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: #374151;
    border-bottom: 1px solid #e5e7eb;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
}

.data-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 8px;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
}

.status-success {
    background-color: #dcfce7;
    color: #166534;
}

.status-warning {
    background-color: #fef3c7;
    color: #92400e;
}

.status-danger {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-info {
    background-color: #dbeafe;
    color: #1e40af;
}

/* Charts Container */
.chart-container {
    position: relative;
    height: 300px;
    width: 100%;
}

/* Activity Feed */
.activity-item {
    display: flex;
    align-items: flex-start;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.activity-item:last-child {
    border-bottom: none;
}

.activity-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    flex-shrink: 0;
}

.activity-content {
    flex: 1;
}

.activity-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #374151;
    margin-bottom: 2px;
}

.activity-time {
    font-size: 0.75rem;
    color: #6b7280;
}

/* Modal Animations */
.modal-enter {
    opacity: 0;
    transform: scale(0.95);
}

.modal-enter-active {
    opacity: 1;
    transform: scale(1);
    transition: all 0.2s ease;
}

/* Loading States */
.loading {
    position: relative;
    pointer-events: none;
}

.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border: 2px solid #f3f4f6;
    border-top: 2px solid #2563eb;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Form Styles */
.form-input {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.875rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

/* Button Styles */
.btn-primary {
    background: linear-gradient(135deg, #2563eb, #1d4ed8);
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-primary:hover {
    background: linear-gradient(135deg, #1d4ed8, #1e40af);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.btn-secondary {
    background: #f9fafb;
    color: #374151;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    border: 1px solid #d1d5db;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-secondary:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.btn-danger {
    background: #dc2626;
    color: white;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
}

.btn-danger:hover {
    background: #b91c1c;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(220, 38, 38, 0.3);
}

/* Dropdown Menu */
.dropdown {
    position: relative;
}

.dropdown-menu {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 10;
    margin-top: 8px;
    width: 200px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.2s ease;
}

.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-item {
    display: block;
    width: 100%;
    padding: 8px 16px;
    text-align: left;
    border: none;
    background: none;
    color: #374151;
    font-size: 0.875rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.dropdown-item:hover {
    background-color: #f9fafb;
}

/* Notification System */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 8px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
    border-left: 4px solid #2563eb;
    padding: 16px;
    max-width: 400px;
    z-index: 1000;
    transform: translateX(100%);
    transition: transform 0.3s ease;
}

.notification.show {
    transform: translateX(0);
}

.notification-success {
    border-left-color: #10b981;
}

.notification-error {
    border-left-color: #ef4444;
}

.notification-warning {
    border-left-color: #f59e0b;
}

.notification-content {
    display: flex;
    align-items: flex-start;
    gap: 12px;
}

.notification-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.notification-success .notification-icon {
    background: #10b981;
}

.notification-error .notification-icon {
    background: #ef4444;
}

.notification-warning .notification-icon {
    background: #f59e0b;
}

.notification-text {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
}

.notification-message {
    font-size: 0.875rem;
    color: #6b7280;
}

.notification-close {
    background: none;
    border: none;
    color: #9ca3af;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    transition: color 0.2s ease;
}

.notification-close:hover {
    color: #374151;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .mobile-overlay {
        display: block !important;
    }

    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }

    .charts-grid {
        grid-template-columns: 1fr;
    }

    .data-tables-grid {
        grid-template-columns: 1fr;
    }

    .data-table {
        font-size: 0.75rem;
    }

    .data-table th,
    .data-table td {
        padding: 8px;
    }
}

@media (max-width: 640px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }

    .header-actions {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .modal-content {
        margin: 16px;
        width: calc(100% - 32px);
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .sidebar {
        background: #000;
        color: #fff;
    }

    .nav-link:hover,
    .nav-link.active {
        background: #fff;
        color: #000;
    }

    .stats-card {
        border: 2px solid #000;
    }
}

/* Focus States */
.btn:focus,
.form-input:focus,
.nav-link:focus {
    outline: 2px solid #2563eb;
    outline-offset: 2px;
}

/* Print Styles */
@media print {
    .sidebar,
    .header-actions,
    .notification,
    .modal {
        display: none !important;
    }

    body {
        background: white !important;
    }

    .main-content {
        margin-left: 0 !important;
    }
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #111827;
        color: #f9fafb;
    }

    .sidebar {
        background-color: #1f2937;
        color: #f9fafb;
    }

    .nav-link {
        color: #d1d5db;
    }

    .nav-link:hover,
    .nav-link.active {
        background-color: #374151;
        color: #f9fafb;
    }

    .stats-card {
        background-color: #1f2937;
        color: #f9fafb;
        border-color: #374151;
    }

    .data-table th {
        background-color: #374151;
        color: #f9fafb;
    }

    .data-table td {
        border-color: #374151;
    }

    .activity-item {
        border-color: #374151;
    }
}

/* Performance Badge */
.performance-badge {
    animation: badgePulse 3s infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.9;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Loading Skeleton */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* Error States */
.error-state {
    background-color: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
    padding: 12px;
    border-radius: 6px;
}

/* Success States */
.success-state {
    background-color: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #16a34a;
    padding: 12px;
    border-radius: 6px;
}