/* --- Global Reset & Base --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    /* Apple's system font stack */
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, 
                 Helvetica, Arial, sans-serif, "Apple Color Emoji";
    background-color: #121212; /* Dark background */
    color: #f5f5f7;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    min-height: 100vh;
}

/* --- Login Page Styling --- */
.login-container {
    width: 100%;
    max-width: 400px;
    padding: 2.5rem;
    
    /* The "Frosted Glass" / Glossy Effect */
    background: rgba(30, 30, 30, 0.75);
    backdrop-filter: blur(20px) saturate(180%);
    -webkit-backdrop-filter: blur(20px) saturate(180%);
    
    border-radius: 24px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    text-align: center;
}

.login-container h2 {
    font-size: 2rem;
    font-weight: 600;
    margin-bottom: 1.5rem;
    color: #fff;
}

.login-container .input-group {
    margin-bottom: 1.25rem;
    text-align: left;
}

.login-container .input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #a0a0a0;
}

.login-container .input-group input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    background-color: rgba(60, 60, 60, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    color: #f5f5f7;
    transition: all 0.3s ease;
}

.login-container .input-group input:focus {
    outline: none;
    border-color: #007aff; /* Apple Blue */
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

.login-button {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background-color: #007aff; /* Apple Blue */
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background-color 0.3s ease, transform 0.1s ease;
}

.login-button:hover {
    background-color: #0a84ff;
}

.login-button:active {
    transform: scale(0.98);
}

.error-message {
    background-color: rgba(255, 59, 48, 0.2);
    color: #ff3b30;
    padding: 0.75rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

/* --- Dashboard Styling --- */
.dashboard-container {
    display: grid;
    grid-template-columns: 240px 1fr; /* Sidebar and main content */
    width: 100vw;
    height: 100vh;
    background: radial-gradient(circle at top right, #1a1a1c, #000); /* Match homepage */
    align-items: start;
}

.sidebar {
    background: #2c2c2e;
    height: 100%;
    padding: 2rem 1.5rem;
    transition: transform 0.3s ease, width 0.3s ease;
    overflow-y: auto; /* Ensure sidebar content scrolls if tall */
}

/* Hidden sidebar */
/* --- Mobile Menu Button --- */
.mobile-menu-btn {
    display: none; /* Hidden on desktop */
    background: #3a3a3c;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 50%;
    color: #f5f5f7;
    font-size: 1.2rem;
    cursor: pointer;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1001;
    margin-bottom: 1rem;
    transition: background-color 0.2s ease;
}
.mobile-menu-btn:hover {
    background: #48484a;
}



/* Sidebar overlay for mobile */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    backdrop-filter: blur(2px);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

.sidebar h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: #fff;
    margin-bottom: 2rem;
}

.sidebar nav a {
    display: block;
    padding: 0.9rem 1rem;
    text-decoration: none;
    color: #a0a0a0;
    border-radius: 10px;
    font-weight: 500;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.sidebar nav a:hover,
.sidebar nav a.active {
    background-color: #007aff;
    color: #fff;
}

.sidebar .logout {
    position: absolute;
    bottom: 2rem;
    width: calc(240px - 3rem); /* Sidebar width - padding */
    background-color: rgba(255, 59, 48, 0.8);
}

.main-content {
    padding: 2rem;
    height: 100vh;
    overflow-y: auto;
}

.main-content h2 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 1.5rem;
}

/* --- Widgets & Search --- */
.widget, .pos-section {
    /* Match homepage glass-card */
    background: #1c1c1e;
    border-radius: 18px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.widget:hover, .pos-section:hover {
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.widget h3 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 1rem;
    color: #f5f5f7;
}

.widget ul {
    list-style: none;
}

.widget li {
    padding: 0.5rem 0;
    border-bottom: 1px solid #424245;
    color: #ff453a; /* Alert color */
    font-weight: 500;
}

.widget li:last-child {
    border-bottom: none;
}

.search-bar {
    width: 100%;
    padding: 1rem 1.25rem;
    font-size: 1.1rem;
    background-color: #1c1c1e;
    border: 1px solid #3a3a3c;
    border-radius: 12px;
    color: #f5f5f7;
    margin-bottom: 1rem;
    transition: all 0.2s ease;
}

.search-bar:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

#search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}
/* --- New Form Styles --- */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.action-button, .action-button-secondary {
    padding: 0.6rem 1.2rem;
    font-size: 0.9rem;
    font-weight: 600;
    color: #fff;
    background-color: #007aff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
}

.action-button:hover {
    background-color: #0a84ff;
}

.action-button-secondary {
    background-color: #3a3a3c;
}
.action-button-secondary:hover {
    background-color: #48484a;
}

.form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
}

.form-group.full-width {
    grid-column: 1 / -1; /* Span full width */
}

.form-group label {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
    color: #a0a0a0;
}

.form-input {
    width: 100%;
    padding: 0.9rem 1rem;
    font-size: 1rem;
    background-color: #1d1d1f;
    border: 1px solid #424245;
    border-radius: 12px;
    color: #f5f5f7;
    transition: all 0.3s ease;
}

.form-input:focus {
    outline: none;
    border-color: #007aff;
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.25);
}

.form-group small {
    margin-top: 0.5rem;
    font-size: 0.8rem;
    color: #8e8e93;
}

.success-message {
    background-color: rgba(52, 199, 89, 0.2);
    color: #34c759;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    font-weight: 500;
}


/* --- New Table Styles --- */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid #424245;
}

.data-table th {
    font-size: 0.9rem;
    color: #a0a0a0;
    font-weight: 600;
    text-transform: uppercase;
}

.data-table td {
    color: #f5f5f7;
}

.data-table .models-cell {
    max-width: 300px;
    white-space: normal;
    word-break: break-word;
    font-size: 0.9rem;
    color: #a0a0a0;
}

.data-table tr {
    transition: background-color 0.2s ease;
}
.data-table tr:hover {
    background-color: rgba(255, 255, 255, 0.03);
}
/* --- New Model Page Styles --- */
.page-grid {
    display: grid;
    grid-template-columns: 1fr 1.5fr; /* 1 column for form, 1.5 for list */
    gap: 1.5rem;
    align-items: flex-start;
}

.form-grid-simple .form-group {
    grid-column: 1 / -1; /* Make input full width */
}

.form-grid-simple .form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

/* Make buttons smaller for this form */
.form-grid-simple .login-button,
.form-grid-simple .action-button-secondary {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    width: auto;
}


/* --- Table Action Buttons --- */
.data-table .actions-column {
    width: 150px; /* Give actions column a fixed width */
    text-align: right;
}

.data-table td .table-action-button {
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 7px;
    transition: all 0.2s ease;
}

.table-action-button.edit {
    color: #007aff;
    background-color: rgba(0, 122, 255, 0.15);
}
.table-action-button.edit:hover {
    background-color: rgba(0, 122, 255, 0.3);
}

.table-action-button.delete {
    color: #ff3b30;
    background-color: rgba(255, 59, 48, 0.15);
}
.table-action-button.delete:hover {
    background-color: rgba(255, 59, 48, 0.3);
}
/* --- Table Action Buttons (For Products & Models) --- */
.data-table .actions-column {
    width: 150px; 
    text-align: right;
}

.data-table td .table-action-button {
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 7px;
    transition: all 0.2s ease;
    margin-left: 0.5rem; /* Separator for multiple buttons */
}

.table-action-button.edit {
    color: #007aff;
    background-color: rgba(0, 122, 255, 0.15);
}

.table-action-button.edit:hover {
    background-color: rgba(0, 122, 255, 0.3);
}

.table-action-button.delete {
    color: #ff3b30;
    background-color: rgba(255, 59, 48, 0.15);
}

.table-action-button.delete:hover {
    background-color: rgba(255, 59, 48, 0.3);
}

/* --- POS Search and Cart Styles --- */

#search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.product-card {
    background: #2c2c2e;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.08); /* Enhance border */
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.card-info {
    margin-bottom: 1rem;
}

.card-info strong {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.5rem;
    color: #fff;
}

.compatible-models-text {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 0.5rem;
}

.price-tag {
    font-size: 1.4rem;
    font-weight: 700;
    color: #34c759; /* Green for price */
}

.stock-info {
    font-size: 0.9rem;
    color: #8e8e93;
    margin-top: 0.5rem;
}

.add-to-cart-button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background-color: #ff9500; /* Apple orange for action */
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.add-to-cart-button:hover:not(:disabled) {
    background-color: #ffb84d;
}

.add-to-cart-button:disabled {
    background-color: #424245;
    cursor: not-allowed;
    color: #a0a0a0;
}

/* Cart Display Styling */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px dashed #424245;
    font-size: 0.95rem;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-controls {
    display: flex;
    gap: 1rem;
    color: #a0a0a0;
}

.cart-item-total {
    font-weight: 600;
    color: #f5f5f7;
}
/* Sales History Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
    grid-template-columns: 1fr 1.5fr; /* 1 column for form, 1.5 for list */
    gap: 1.5rem;
    align-items: flex-start;
}

.form-grid-simple .form-group {
    grid-column: 1 / -1; /* Make input full width */
}

.form-grid-simple .form-actions {
    grid-column: 1 / -1;
    display: flex;
    gap: 1rem;
    align-items: center;
    margin-top: 1rem;
}

/* Make buttons smaller for this form */
.form-grid-simple .login-button,
.form-grid-simple .action-button-secondary {
    padding: 0.7rem 1.2rem;
    font-size: 0.9rem;
    width: auto;
}


/* --- Table Action Buttons --- */
.data-table .actions-column {
    width: 150px; /* Give actions column a fixed width */
    text-align: right;
}

.data-table td .table-action-button {
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 7px;
    transition: all 0.2s ease;
}

.table-action-button.edit {
    color: #007aff;
    background-color: rgba(0, 122, 255, 0.15);
}
.table-action-button.edit:hover {
    background-color: rgba(0, 122, 255, 0.3);
}

.table-action-button.delete {
    color: #ff3b30;
    background-color: rgba(255, 59, 48, 0.15);
}
.table-action-button.delete:hover {
    background-color: rgba(255, 59, 48, 0.3);
}
/* --- Table Action Buttons (For Products & Models) --- */
.data-table .actions-column {
    width: 150px; 
    text-align: right;
}

.data-table td .table-action-button {
    text-decoration: none;
    padding: 0.3rem 0.7rem;
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: 7px;
    transition: all 0.2s ease;
    margin-left: 0.5rem; /* Separator for multiple buttons */
}

.table-action-button.edit {
    color: #007aff;
    background-color: rgba(0, 122, 255, 0.15);
}

.table-action-button.edit:hover {
    background-color: rgba(0, 122, 255, 0.3);
}

.table-action-button.delete {
    color: #ff3b30;
    background-color: rgba(255, 59, 48, 0.15);
}

.table-action-button.delete:hover {
    background-color: rgba(255, 59, 48, 0.3);
}

/* --- POS Search and Cart Styles --- */

#search-results {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-top: 1rem;
}

.product-card {
    background: #2c2c2e;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

.card-info {
    margin-bottom: 1rem;
}

.card-info strong {
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.5rem;
    color: #fff;
}

.compatible-models-text {
    font-size: 0.85rem;
    color: #a0a0a0;
    margin-bottom: 0.5rem;
}

.price-tag {
    font-size: 1.4rem;
    font-weight: 700;
    color: #34c759; /* Green for price */
}

.stock-info {
    font-size: 0.9rem;
    color: #8e8e93;
    margin-top: 0.5rem;
}

.add-to-cart-button {
    padding: 0.75rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #fff;
    background-color: #ff9500; /* Apple orange for action */
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: background-color 0.2s ease, transform 0.1s ease;
}

.add-to-cart-button:hover:not(:disabled) {
    background-color: #ffb84d;
}

.add-to-cart-button:disabled {
    background-color: #424245;
    cursor: not-allowed;
    color: #a0a0a0;
}

/* Cart Display Styling */
.cart-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px dashed #424245;
    font-size: 0.95rem;
}

.cart-item:last-child {
    border-bottom: none;
}

.cart-controls {
    display: flex;
    gap: 1rem;
    color: #a0a0a0;
}

.cart-item-total {
    font-weight: 600;
    color: #f5f5f7;
}
/* Sales History Detail Grid */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid #424245;
    margin-bottom: 1rem;
}

.detail-grid p {
    margin: 0;
}

/* --- Dashboard Stats Grid --- */
.dashboard-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: #1c1c1e; /* Match homepage glass-card */
    backdrop-filter: blur(20px);
    padding: 1.75rem;
    border-radius: 18px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0, 122, 255, 0.03) 0%, transparent 100%);
    opacity: 0;
    transition: opacity 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-8px); /* Match homepage hover */
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
    border-color: rgba(255, 255, 255, 0.1);
}

.stat-card:hover::before {
    opacity: 1;
}

.stat-card h3 {
    font-size: 0.75rem;
    color: #8e8e93;
    margin-bottom: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.stat-icon {
    width: 36px;
    height: 36px;
    background: rgba(0, 122, 255, 0.15);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.75rem;
}

.stat-icon svg {
    width: 18px;
    height: 18px;
    stroke: #007aff;
}

.stat-number {
    font-size: 2.5rem;
    font-weight: 700;
    color: #ffffff;
    margin-bottom: 0.4rem;
    line-height: 1.1;
}

.stat-label {
    font-size: 0.85rem;
    color: #34c759;
    font-weight: 500;
}

/* --- Dashboard Widgets Grid --- */
.dashboard-widgets-grid {
    display: grid;
    grid-template-columns: 2fr 1fr; /* Main chart/table wider than side list */
    gap: 1.5rem;
}

@media (max-width: 1000px) {
    .dashboard-widgets-grid {
        grid-template-columns: 1fr;
    }
}

/* --- Responsive Adjustments (Mobile) --- */
@media (max-width: 768px) {
    /* Login Page Mobile Fix */
    .login-container {
        padding: 1.5rem;
        max-width: 90%;
    }

    .dashboard-container {
        display: block; /* Stack layout */
        height: auto;
        min-height: 100vh;
    }

    /* Show hamburger */
    .mobile-menu-btn {
        display: block;
    }

    /* Sidebar: Fixed Off-Canvas */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 260px; /* Fixed width */
        transform: translateX(-100%); /* Hidden by default */
        box-shadow: 5px 0 15px rgba(0,0,0,0.3);
        z-index: 1000; /* Above overlay */
    }

    /* Active class to show sidebar */
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main-content {
        padding: 1.5rem 1rem;
        width: 100%;
        margin-left: 0;
        height: auto; /* Allow content to grow */
        overflow-y: visible; /* Remove internal scrollbar on mobile */
    }

    /* Grid Adjustments for Mobile */
    .dashboard-stats-grid,
    .dashboard-widgets-grid,
    .page-grid,
    .form-grid,
    .detail-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    /* POS Specific */
    .pos-grid {
        flex-direction: column;
    }
    .pos-main, .pos-sidebar {
        width: 100%;
    }
    
    /* Table Adjustments: Horizontal Scroll */
    .widget {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch; /* Smooth scroll on iOS */
    }
    .data-table {
        min-width: 600px; /* Force scroll for wide tables */
    }
    
    /* Make first column sticky on mobile for context */
    .data-table th:first-child,
    .data-table td:first-child {
        position: sticky;
        left: 0;
        background-color: #2c2c2e; /* Match widget bg */
        z-index: 10;
        box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    }
    
    .product-card {
        min-width: 100%;
    }
    #search-results {
        grid-template-columns: 1fr;
    }

    /* Scaling Typography */
    .main-content h2, 
    .login-container h2 {
        font-size: 1.8rem;
    }
    
    .stat-number {
        font-size: 2rem;
    }

    /* Form Usability on Mobile */
    .form-input, 
    .search-bar,
    .login-container .input-group input {
        font-size: 16px !important; /* Prevent iOS zoom */
        padding: 12px;
    }
    
    .action-button, 
    .action-button-secondary,
    .login-button {
        padding: 12px 16px; /* Larger touch targets */
        width: 100%; /* Full width buttons on mobile */
        text-align: center;
        margin-bottom: 0.5rem;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .page-header .action-button,
    .page-header .action-button-secondary {
        width: 100%;
        text-align: center;
    }
}


.low-stock-list {
    list-style: none;
}

.low-stock-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid #424245;
}

.low-stock-item:last-child {
    border-bottom: none;
}

.low-stock-item .product-name {
    font-weight: 500;
    color: #f5f5f7;
}

.low-stock-item .stock-count.warning {
    color: #ff9500;
    font-weight: 600;
    background: rgba(255, 149, 0, 0.15);
    padding: 0.2rem 0.6rem;
    border-radius: 6px;
    font-size: 0.85rem;
}