:root {
    --primary: #4F46E5;
    --primary-dark: #3730A3;
    --primary-light: #818CF8;
    --secondary: #10B981;
    --danger: #EF4444;
    --info: #3B82F6;
    --dark: #1E293B;
    --gray: #64748B;
    --light: #F1F5F9;
    --white: #FFFFFF;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: var(--light);
    color: var(--dark);
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* Screens */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}
.screen.active {
    display: flex;
}

/* Login Screen */
#login-screen {
    justify-content: center;
    align-items: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.login-card {
    background: var(--white);
    padding: 30px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 400px;
    text-align: center;
}
.logo-area {
    margin-bottom: 30px;
    color: var(--primary);
}
.logo-area i {
    font-size: 3rem;
    margin-bottom: 10px;
}
.logo-area h1 {
    font-weight: 700;
    font-size: 1.5rem;
}

/* Forms */
.input-group {
    margin-bottom: 15px;
    text-align: left;
}
.input-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--gray);
}
.input-group input, .input-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid #CBD5E1;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s, box-shadow 0.3s;
}
.input-group input:focus, .input-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.2);
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
}
.btn-block { width: 100%; }
.btn-primary { background: var(--primary); color: var(--white); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--gray); color: var(--white); }
.btn-success { background: var(--secondary); color: var(--white); }
.btn-info { background: var(--info); color: var(--white); }
.btn-danger { background: var(--danger); color: var(--white); }

/* App Layout */
#app-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
}
.app-header {
    background: var(--white);
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    z-index: 10;
}
.app-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}
.app-header button {
    background: none;
    border: none;
    color: var(--gray);
    font-size: 1.2rem;
    cursor: pointer;
}

.app-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    padding-bottom: 80px; /* Space for bottom nav */
}

/* Views */
.view {
    display: none;
    animation: fadeIn 0.3s ease;
}
.view.active {
    display: block;
}
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Cards & Lists */
.card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 20px;
    box-shadow: var(--shadow-md);
    margin-bottom: 20px;
}
.gradient-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
    color: var(--white);
}
.summary-card h3 { font-size: 1rem; opacity: 0.9; margin-bottom: 10px; }
.summary-card .amount { font-size: 2.5rem; font-weight: 700; }

.section-title {
    font-size: 1.1rem;
    color: var(--gray);
    margin-bottom: 15px;
}

.list-item {
    background: var(--white);
    border-radius: var(--radius);
    padding: 15px;
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform 0.2s;
}
.list-item:active { transform: scale(0.98); }
.list-item-content h4 { font-size: 1rem; margin-bottom: 4px; }
.list-item-content p { font-size: 0.85rem; color: var(--gray); }
.list-item-action { font-weight: 600; font-size: 1.1rem; }
.text-danger { color: var(--danger); }
.text-success { color: var(--secondary); }
.text-primary { color: var(--primary); }

.grid-layout {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
}
.product-card {
    background: var(--white);
    border-radius: var(--radius);
    padding: 15px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    position: relative;
    cursor: pointer;
}
.product-card h4 { font-size: 1rem; margin-bottom: 10px; }
.product-card .price { font-weight: 700; color: var(--primary); font-size: 1.1rem; }
.product-card .stock { font-size: 0.8rem; color: var(--gray); margin-top: 5px; }

/* Action Bar */
.action-bar {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.search-input {
    flex: 1;
    padding: 12px 15px;
    border: 1px solid #CBD5E1;
    border-radius: var(--radius);
    font-size: 1rem;
}

/* Bottom Nav */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background: var(--white);
    display: flex;
    justify-content: space-around;
    padding: 10px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 100;
}
.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray);
    padding: 8px 20px;
    border-radius: 12px;
    transition: all 0.3s;
}
.nav-item i { font-size: 1.2rem; margin-bottom: 4px; }
.nav-item span { font-size: 0.75rem; font-weight: 500; }
.nav-item.active {
    color: var(--primary);
}

/* Modals */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    justify-content: center;
    align-items: flex-end; /* Bottom sheet style for mobile */
}
.modal.active { display: flex; }
.modal-content {
    background: var(--white);
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 25px 20px;
    border-radius: 20px 20px 0 0;
    position: relative;
    animation: slideUp 0.3s ease;
}
@media (min-width: 600px) {
    .modal { align-items: center; }
    .modal-content { width: 90%; max-width: 500px; border-radius: var(--radius); }
}
@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}
.close-modal {
    position: absolute;
    top: 15px;
    right: 20px;
    font-size: 1.5rem;
    color: var(--gray);
    cursor: pointer;
}
.modal-content h2 { margin-bottom: 20px; font-size: 1.4rem; }

/* Detail View */
.btn-back {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
}
.client-header { text-align: center; }
.client-header h2 { margin-bottom: 5px; }
.client-header p { color: var(--gray); font-size: 0.9rem; margin-bottom: 5px; }
.balance-badge {
    display: inline-block;
    padding: 8px 15px;
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border-radius: 20px;
    font-weight: 700;
    font-size: 1.2rem;
    margin-top: 10px;
}
.detail-actions {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.detail-actions .btn { flex: 1; }

.tabs {
    display: flex;
    border-bottom: 2px solid #E2E8F0;
    margin-bottom: 15px;
}
.tab-btn {
    flex: 1;
    background: none;
    border: none;
    padding: 10px;
    font-weight: 600;
    color: var(--gray);
    cursor: pointer;
    position: relative;
}
.tab-btn.active { color: var(--primary); }
.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    width: 100%;
    height: 2px;
    background: var(--primary);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* Sale Items Selector */
.product-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}
.product-selector select { flex: 1; padding: 10px; border-radius: 8px; border: 1px solid #CBD5E1; }
.qty-input { width: 70px; padding: 10px; border-radius: 8px; border: 1px solid #CBD5E1; text-align: center; }
.item-list { list-style: none; margin-bottom: 20px; }
.item-list li {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #E2E8F0;
}
.remove-item { color: var(--danger); background: none; border: none; cursor: pointer; }
.sale-summary { text-align: right; margin-bottom: 20px; font-size: 1.2rem; }

/* Toast */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: var(--dark);
    color: var(--white);
    padding: 12px 20px;
    border-radius: 30px;
    font-size: 0.9rem;
    font-weight: 500;
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
    box-shadow: var(--shadow-md);
}
.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.text-muted { color: var(--gray); font-size: 0.9rem; margin-bottom: 15px;}
.error-msg { color: var(--danger); font-size: 0.9rem; margin-top: 10px; text-align: center;}
