:root {
    --primary: #6c5ce7;
    --primary-dark: #5a4bd1;
    --primary-light: #a29bfe;
    --success: #00b894;
    --success-dark: #00a381;
    --danger: #e17055;
    --danger-dark: #d35940;
    --warning: #fdcb6e;
    --dark: #2d3436;
    --gray-900: #1a1a2e;
    --gray-800: #2d2d44;
    --gray-700: #3d3d56;
    --gray-600: #636e72;
    --gray-400: #b2bec3;
    --gray-200: #dfe6e9;
    --gray-100: #f1f2f6;
    --white: #ffffff;
    --shadow: 0 2px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 40px rgba(0, 0, 0, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
    line-height: 1.6;
}

/* === LOGIN === */
.login-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 20px;
}

.login-box {
    background: var(--white);
    border-radius: var(--radius);
    padding: 50px 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
    text-align: center;
}

.login-icon {
    font-size: 3rem;
    color: var(--primary);
    margin-bottom: 20px;
}

.login-box h1 {
    font-size: 1.8rem;
    color: var(--dark);
    margin-bottom: 8px;
}

.login-subtitle {
    color: var(--gray-600);
    margin-bottom: 30px;
    font-size: 0.95rem;
}

.login-form .input-group {
    position: relative;
    margin-bottom: 20px;
}

.login-form .input-group i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-400);
}

.login-form .input-group input {
    width: 100%;
    padding: 14px 14px 14px 45px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    outline: none;
}

.login-form .input-group input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

/* === ALERTS === */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background: #ffeef0;
    color: var(--danger);
    border: 1px solid #ffcdd2;
}

/* === BUTTONS === */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
}

.btn-primary:hover {
    background: var(--primary-dark);
}

.btn-success {
    background: var(--success);
    color: var(--white);
}

.btn-success:hover {
    background: var(--success-dark);
}

.btn-danger {
    background: var(--danger);
    color: var(--white);
}

.btn-danger:hover {
    background: var(--danger-dark);
}

.btn-secondary {
    background: var(--gray-200);
    color: var(--dark);
}

.btn-secondary:hover {
    background: var(--gray-400);
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: 14px;
    font-size: 1rem;
}

.btn-sm {
    padding: 8px 12px;
    font-size: 0.8rem;
}

.btn-icon {
    padding: 8px 10px;
    font-size: 0.85rem;
}

.btn-logout {
    background: rgba(255, 255, 255, 0.2);
    color: var(--white);
    padding: 8px 12px;
}

.btn-logout:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* === APP LAYOUT === */
.app-container {
    min-height: 100vh;
    background: var(--gray-100);
}

.app-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-icon {
    font-size: 1.5rem;
    color: var(--white);
}

.app-header h1 {
    color: var(--white);
    font-size: 1.3rem;
    font-weight: 700;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.grand-total-badge {
    background: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    padding: 8px 16px;
    border-radius: 20px;
    color: var(--white);
    font-weight: 700;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    gap: 8px;
}

.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 24px;
}

/* === ACTION BAR === */
.action-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
    flex-wrap: wrap;
}

/* === CATEGORIES === */
.categories-container {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.category-card {
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: var(--transition);
}

.category-card:hover {
    box-shadow: var(--shadow-lg);
}

.category-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-bottom: 1px solid var(--gray-200);
    cursor: pointer;
    user-select: none;
    transition: var(--transition);
}

.category-header:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
}

.category-title {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--dark);
}

.category-title .cat-icon {
    color: var(--primary);
}

.category-title .cat-toggle {
    font-size: 0.75rem;
    color: var(--gray-600);
    transition: transform 0.3s ease;
}

.category-card.open .cat-toggle {
    transform: rotate(90deg);
}

.category-total {
    font-size: 0.85rem;
    color: var(--gray-600);
    background: var(--white);
    padding: 4px 12px;
    border-radius: 12px;
    font-weight: 600;
}

.category-actions {
    display: flex;
    gap: 8px;
}

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 20px;
}

.product-card {
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 16px;
    transition: var(--transition);
    position: relative;
}

.product-card:hover {
    border-color: var(--primary-light);
    box-shadow: 0 4px 15px rgba(108, 92, 231, 0.1);
}

.product-card.selected {
    border-color: var(--danger);
    background: #fff5f5;
}

.product-checkbox {
    position: absolute;
    top: 12px;
    left: 12px;
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: var(--primary);
}

.product-image {
    width: 100%;
    height: 160px;
    object-fit: contain;
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    background: var(--gray-100);
}

.product-image-placeholder {
    width: 100%;
    height: 160px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    margin-bottom: 12px;
    color: var(--gray-400);
    font-size: 2.5rem;
}

.product-name {
    font-weight: 600;
    font-size: 0.95rem;
    margin-bottom: 6px;
    color: var(--dark);
}

.product-price {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 10px;
}

.product-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    color: var(--primary);
    text-decoration: none;
    font-size: 0.8rem;
    margin-bottom: 12px;
}

.product-link:hover {
    text-decoration: underline;
}

.product-actions {
    display: flex;
    gap: 8px;
    padding-top: 10px;
    border-top: 1px solid var(--gray-200);
}

/* === STATS === */
.stats-section {
    margin-top: 40px;
}

.section-title {
    font-size: 1.3rem;
    color: var(--dark);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow);
}

.stat-card h3 {
    font-size: 1rem;
    color: var(--gray-600);
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.stat-card-highlight {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: var(--white);
}

.stat-card-highlight h3 {
    color: rgba(255, 255, 255, 0.8);
}

.grand-total {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
}

.product-count {
    font-size: 0.95rem;
    opacity: 0.8;
}

.stat-list-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
    border-bottom: 1px solid var(--gray-200);
}

.stat-list-item:last-child {
    border-bottom: none;
}

.stat-list-item .item-name {
    font-weight: 500;
    font-size: 0.9rem;
}

.stat-list-item .item-category {
    font-size: 0.75rem;
    color: var(--gray-600);
}

.stat-list-item .item-price {
    font-weight: 700;
    color: var(--primary);
    white-space: nowrap;
}

.text-danger {
    color: var(--danger);
}

.text-success {
    color: var(--success);
}

/* === MODAL === */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active {
    display: flex;
}

.modal {
    background: var(--white);
    border-radius: var(--radius);
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1.2rem;
    color: var(--dark);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-600);
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition);
}

.modal-close:hover {
    background: var(--gray-100);
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
}

/* === FORM === */
.form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--gray-600);
    margin-bottom: 6px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.form-input {
    width: 100%;
    padding: 12px 14px;
    border: 2px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 0.95rem;
    transition: var(--transition);
    outline: none;
    font-family: inherit;
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
}

.input-with-btn {
    display: flex;
    gap: 8px;
}

.input-with-btn .form-input {
    flex: 1;
}

.image-preview {
    margin-top: 10px;
}

.image-preview img {
    max-width: 100%;
    max-height: 150px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--gray-200);
}

/* === TOAST === */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    padding: 14px 24px;
    background: var(--dark);
    color: var(--white);
    border-radius: var(--radius-sm);
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    transform: translateY(100px);
    opacity: 0;
    transition: var(--transition);
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* === LOADING === */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--gray-600);
    font-size: 1rem;
}

/* === EMPTY STATE === */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--gray-600);
}

.empty-state i {
    font-size: 3rem;
    color: var(--gray-400);
    margin-bottom: 12px;
}

.empty-state p {
    font-size: 0.95rem;
}

/* === RESPONSIVE === */
@media (max-width: 768px) {
    .app-header {
        padding: 12px 16px;
    }

    .app-header h1 {
        font-size: 1rem;
    }

    .grand-total-badge {
        padding: 6px 10px;
        font-size: 0.8rem;
    }

    .main-content {
        padding: 16px;
    }

    .action-bar {
        gap: 8px;
    }

    .btn {
        padding: 8px 12px;
        font-size: 0.8rem;
    }

    .btn-text {
        display: none;
    }

    .category-header {
        padding: 14px 16px;
        flex-wrap: wrap;
        gap: 8px;
    }

    .category-title {
        font-size: 1rem;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
        padding: 12px;
        gap: 12px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .grand-total {
        font-size: 2rem;
    }

    .modal {
        max-width: 100%;
        margin: 10px;
    }

    .toast {
        left: 16px;
        right: 16px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: 1fr;
    }

    .header-left h1 {
        display: none;
    }

    .product-image,
    .product-image-placeholder {
        height: 120px;
    }
}

/* === SELECT STYLING === */
select.form-input {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23636e72' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 14px center;
    padding-right: 36px;
}

/* === SCROLLBAR === */
::-webkit-scrollbar {
    width: 8px;
}

::-webkit-scrollbar-track {
    background: var(--gray-100);
}

::-webkit-scrollbar-thumb {
    background: var(--gray-400);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--gray-600);
}
