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

:root {
    --primary-color: #2563eb;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --danger-color: #ef4444;
    --warning-color: #f59e0b;
    --info-color: #3b82f6;
    --dark-color: #1e293b;
    --light-color: #f8fafc;
    --border-color: #e2e8f0;
    --text-color: #334155;
    --sidebar-width: 260px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    line-height: 1.6;
    color: var(--text-color);
    background-color: var(--light-color);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 20px;
}

.login-box {
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    padding: 40px;
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-header h1 {
    font-size: 36px;
    font-weight: bold;
    color: var(--primary-color);
    margin-bottom: 5px;
}

.login-header p {
    color: var(--secondary-color);
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

.login-footer p {
    font-size: 12px;
    color: var(--secondary-color);
}

/* Layout */
.wrapper {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    background: var(--dark-color);
    color: white;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    z-index: 1000;
    transition: transform 0.3s ease;
}

.sidebar-header {
    padding: 25px 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 5px;
}

.sidebar-header p {
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
}

.sidebar-nav {
    padding: 20px 0;
}

.nav-section {
    padding: 15px 20px 10px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: rgba(255, 255, 255, 0.5);
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: var(--primary-color);
    color: white;
    border-left: 4px solid white;
}

.nav-icon {
    font-size: 18px;
    margin-right: 12px;
    width: 24px;
    text-align: center;
}

.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

.top-bar {
    background: white;
    border-bottom: 1px solid var(--border-color);
    padding: 15px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
}

.btn-menu {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-color);
}

.user-info {
    font-weight: 500;
    color: var(--text-color);
}

.content {
    flex: 1;
    padding: 30px;
}

.footer {
    background: white;
    border-top: 1px solid var(--border-color);
    padding: 20px 30px;
    text-align: center;
    font-size: 12px;
    color: var(--secondary-color);
}

/* Page Header */
.page-header {
    margin-bottom: 30px;
}

.page-header h1 {
    font-size: 28px;
    font-weight: 600;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.page-header p {
    color: var(--secondary-color);
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--text-color);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    font-size: 14px;
    transition: border-color 0.2s ease;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

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

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-primary:hover {
    background: #1d4ed8;
}

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

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

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

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

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

.btn-secondary:hover {
    background: #475569;
}

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

.btn-block {
    width: 100%;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.alert-success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.alert-error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.alert-warning {
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-info {
    background: #dbeafe;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Tables */
.table-responsive {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 5px;
    overflow: hidden;
}

.table thead {
    background: var(--light-color);
}

.table th {
    padding: 12px;
    text-align: left;
    font-weight: 600;
    color: var(--text-color);
    border-bottom: 2px solid var(--border-color);
}

.table td {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
}

.table tbody tr:hover {
    background: var(--light-color);
}

.table tbody tr:last-child td {
    border-bottom: none;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

/* Badges */
.badge {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 3px;
    text-transform: uppercase;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-warning {
    background: #fef3c7;
    color: #92400e;
}

.badge-info {
    background: #dbeafe;
    color: #1e40af;
}

.badge-secondary {
    background: #e2e8f0;
    color: #475569;
}

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

.stat-card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    display: flex;
    align-items: center;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border-left: 4px solid var(--primary-color);
}

.stat-card.stat-success {
    border-left-color: var(--success-color);
}

.stat-card.stat-danger {
    border-left-color: var(--danger-color);
}

.stat-card.stat-warning {
    border-left-color: var(--warning-color);
}

.stat-card.stat-info {
    border-left-color: var(--info-color);
}

.stat-icon {
    font-size: 36px;
    margin-right: 15px;
}

.stat-content h3 {
    font-size: 24px;
    font-weight: 700;
    color: var(--dark-color);
    margin-bottom: 5px;
}

.stat-content p {
    font-size: 13px;
    color: var(--secondary-color);
    margin-bottom: 5px;
}

.stat-content small {
    font-size: 11px;
    color: var(--secondary-color);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(400px, 1fr));
    gap: 20px;
}

.dashboard-section {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.dashboard-section h2 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--dark-color);
}

/* Cards */
.card {
    background: white;
    border-radius: 8px;
    padding: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    margin-bottom: 20px;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark-color);
}

.card-body {
    padding: 0;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 8px;
    padding: 30px;
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    font-size: 22px;
    font-weight: 600;
    color: var(--dark-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary-color);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid var(--border-color);
}

/* Filters */
.filters {
    background: white;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.filters-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    align-items: end;
}

/* Action Bar */
.action-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.action-bar-left,
.action-bar-right {
    display: flex;
    gap: 10px;
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .btn-menu {
        display: block;
    }
    
    .stats-grid,
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .content {
        padding: 15px;
    }
}

/* Utilities */
.mt-1 { margin-top: 10px; }
.mt-2 { margin-top: 20px; }
.mt-3 { margin-top: 30px; }
.mb-1 { margin-bottom: 10px; }
.mb-2 { margin-bottom: 20px; }
.mb-3 { margin-bottom: 30px; }
.ml-1 { margin-left: 10px; }
.mr-1 { margin-right: 10px; }

.p-1 { padding: 10px; }
.p-2 { padding: 20px; }
.p-3 { padding: 30px; }

.d-flex { display: flex; }
.justify-between { justify-content: space-between; }
.align-center { align-items: center; }
.gap-1 { gap: 10px; }
.gap-2 { gap: 20px; }

/* ============================================
   RESPONSIVE MOBILE STYLES
   ============================================ */

/* Tablet and below (768px) */
@media (max-width: 768px) {
    /* Prevent horizontal scroll */
    html, body {
        overflow-x: hidden;
        width: 100%;
        position: relative;
    }
    
    .wrapper {
        overflow-x: hidden;
        width: 100%;
    }
    
    /* Sidebar - Mobile Menu */
    .sidebar {
        position: fixed;
        left: -260px;
        top: 0;
        height: 100vh;
        z-index: 1000;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    
    .sidebar.active {
        left: 0;
    }
    
    /* Mobile Menu Toggle Button */
    .mobile-menu-toggle {
        display: block;
        position: fixed;
        top: 15px;
        left: 15px;
        z-index: 1001;
        background: var(--primary-color);
        color: white;
        border: none;
        padding: 10px 15px;
        border-radius: 5px;
        cursor: pointer;
        font-size: 20px;
        box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    }
    
    /* Overlay for mobile menu */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Main content adjustments */
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .content {
        padding: 70px 15px 15px;
    }
    
    /* Top bar */
    .top-bar {
        left: 0;
        padding-left: 60px;
    }
    
    /* Page header */
    .page-header {
        padding: 15px 0;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .page-header p {
        font-size: 13px;
    }
    
    /* Action bar */
    .action-bar {
        flex-direction: column;
        gap: 10px;
    }
    
    .action-bar-left,
    .action-bar-right {
        width: 100%;
    }
    
    .action-bar input[type="text"] {
        width: 100% !important;
    }
    
    .action-bar .btn {
        width: 100%;
    }
    
    /* Stats grid */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .stat-card {
        padding: 20px;
    }
    
    /* Dashboard grid */
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .dashboard-section {
        grid-column: 1 !important;
    }
    
    /* Tables */
    .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    .table {
        min-width: 600px;
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 8px;
        white-space: nowrap;
    }
    
    /* Cards */
    .card {
        margin-bottom: 15px;
    }
    
    /* Filters */
    .filters-grid {
        grid-template-columns: 1fr !important;
        gap: 12px;
        padding: 15px;
    }
    
    .filters-row {
        flex-direction: column;
        gap: 10px;
    }
    
    .filters-row .form-group {
        width: 100%;
    }
    
    /* Modals */
    .modal-content {
        width: 95%;
        max-width: 95%;
        margin: 20px auto;
        max-height: 90vh;
        overflow-y: auto;
    }
    
    .modal-header {
        padding: 15px;
    }
    
    .modal-body {
        padding: 15px;
    }
    
    .modal-footer {
        padding: 15px;
        flex-direction: column;
        gap: 10px;
    }
    
    .modal-footer .btn {
        width: 100%;
        margin: 0;
    }
    
    /* Form rows */
    .form-row {
        flex-direction: column;
        gap: 15px;
    }
    
    .form-row .form-group {
        width: 100%;
    }
    
    /* Buttons */
    .btn-group {
        flex-direction: column;
        gap: 5px;
    }
    
    .btn-group .btn {
        width: 100%;
    }
    
    /* Timeline */
    .timeline-item {
        padding-left: 30px;
    }
    
    .timeline-item::before {
        left: 5px;
    }
    
    /* Login page */
    .login-box {
        padding: 30px 20px;
    }
    
    /* Product/Payment action buttons in tables */
    .table td button,
    .table td .btn {
        font-size: 12px;
        padding: 6px 10px;
        margin: 2px 0;
    }
    
    /* Compact badges on mobile */
    .table .badge {
        font-size: 10px;
        padding: 2px 6px;
    }
    
    /* Stack action buttons vertically */
    .table td > div {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }
    
    /* Dashboard specific */
    .quick-actions {
        grid-template-columns: 1fr !important;
    }
    
    .quick-action-card {
        padding: 15px;
    }
    
    /* Top bar user info - hide on mobile */
    .top-bar .user-info span {
        display: none;
    }
    
    .top-bar .user-info {
        font-size: 12px;
    }
    
    /* Compact stat icons */
    .stat-icon {
        font-size: 30px;
        width: 50px;
        height: 50px;
    }
    
    /* Reports page specific */
    .reports-page .stats-grid {
        grid-template-columns: 1fr;
    }
    
    /* Card improvements */
    .card {
        overflow-x: auto;
    }
    
    /* Form improvements */
    input[type="text"],
    input[type="email"],
    input[type="number"],
    input[type="date"],
    select,
    textarea {
        font-size: 16px !important; /* Prevent zoom on iOS */
        width: 100%;
    }
    
    /* Better spacing for mobile */
    .page-header {
        margin-bottom: 15px;
    }
    
    /* Improve stat card layout */
    .stat-card {
        display: flex;
        align-items: center;
        gap: 15px;
    }
    
    .stat-card .stat-icon {
        flex-shrink: 0;
    }
    
    .stat-card .stat-content {
        flex: 1;
        min-width: 0;
    }
    
    .stat-card h3 {
        font-size: 20px;
        margin-bottom: 5px;
    }
    
    .stat-card p {
        font-size: 12px;
        margin-bottom: 3px;
    }
    
    .stat-card small {
        font-size: 10px;
        display: block;
        line-height: 1.3;
    }
    
    /* Better table actions */
    .table td form {
        margin: 2px 0;
    }
    
    .table td .btn-group {
        display: flex;
        flex-direction: column;
        gap: 3px;
    }
    
    /* Modal improvements */
    .modal {
        padding: 10px;
    }
    
    /* Timeline improvements */
    .timeline {
        padding-left: 20px;
    }
}

/* Mobile phones (480px and below) */
@media (max-width: 480px) {
    body {
        font-size: 13px;
    }
    
    .page-header h1 {
        font-size: 20px;
    }
    
    .stat-card h3 {
        font-size: 24px;
    }
    
    .stat-card p {
        font-size: 13px;
    }
    
    .stat-card small {
        font-size: 11px;
    }
    
    .table {
        font-size: 12px;
    }
    
    .table th,
    .table td {
        padding: 6px;
    }
    
    .btn {
        padding: 8px 15px;
        font-size: 13px;
    }
    
    .btn-sm {
        padding: 5px 10px;
        font-size: 12px;
    }
    
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 10px;
        border-radius: 10px;
    }
    
    .badge {
        font-size: 11px;
        padding: 3px 8px;
    }
    
    /* Smaller stat cards */
    .stat-card {
        padding: 15px;
    }
    
    .stat-card h3 {
        font-size: 18px;
    }
    
    .stat-card p {
        font-size: 11px;
    }
    
    .stat-card small {
        font-size: 9px;
    }
    
    /* Compact filters */
    .filters-header h3 {
        font-size: 16px;
    }
    
    .filter-label {
        font-size: 11px;
    }
    
    .filter-select {
        padding: 8px 10px;
        font-size: 13px;
    }
    
    /* Smaller page headers */
    .page-header h1 {
        font-size: 18px;
    }
    
    .page-header p {
        font-size: 12px;
    }
    
    /* Compact action bar */
    .action-bar input[type="text"] {
        padding: 8px 10px;
        font-size: 14px;
    }
    
    /* Better form spacing */
    .form-group {
        margin-bottom: 12px;
    }
    
    .form-group label {
        font-size: 13px;
        margin-bottom: 5px;
    }
    
    /* Compact dashboard sections */
    .dashboard-section h2 {
        font-size: 16px;
        padding: 12px 15px;
    }
    
    /* Better modal sizing */
    .modal-content {
        width: 100%;
        max-width: 100%;
        margin: 5px;
        max-height: 95vh;
    }
    
    .modal-header h2 {
        font-size: 18px;
    }
    
    /* Improve quick actions */
    .quick-action-card {
        padding: 12px;
    }
    
    .quick-action-card h3 {
        font-size: 14px;
    }
    
    /* Better alert spacing */
    .alert {
        padding: 10px;
        font-size: 13px;
        margin-bottom: 10px;
    }
}

/* Landscape phones */
@media (max-width: 768px) and (orientation: landscape) {
    .content {
        padding: 60px 15px 15px;
    }
    
    .modal-content {
        max-height: 85vh;
    }
}

/* Print styles */
@media print {
    .sidebar,
    .top-bar,
    .action-bar,
    .filters,
    .mobile-menu-toggle,
    .sidebar-overlay,
    .btn,
    button {
        display: none !important;
    }
    
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    .content {
        padding: 0 !important;
    }
    
    .table {
        font-size: 10px;
    }
    
    .page-header {
        margin-bottom: 20px;
        border-bottom: 2px solid #000;
    }
}
