/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 12px 20px;
    min-height: 48px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: background 0.15s, transform 0.1s;
    text-decoration: none;
    font-family: inherit;
}
.btn:active { transform: scale(0.97); opacity: 0.85; }
.btn:disabled { opacity: 0.4; pointer-events: none; }
.btn-primary { background: var(--primary); color: white; }
.btn-accent { background: var(--accent); color: #212121; }
.btn-danger { background: var(--danger); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-outline { background: transparent; border: 1.5px solid var(--border); color: var(--text); }
.btn-ghost { background: transparent; color: var(--primary); padding: 8px 12px; min-height: 40px; }
.btn-sm { padding: 8px 14px; min-height: 40px; font-size: 0.85rem; }
.btn-lg { padding: 14px 28px; min-height: 52px; font-size: 1.05rem; }
.btn-block { width: 100%; }
.btn-icon { width: 48px; height: 48px; padding: 0; border-radius: 50%; }

/* Form elements */
.form-group {
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.form-control {
    width: 100%;
    padding: 12px 14px;
    min-height: 48px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    background: white;
    color: var(--text);
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(21,101,192,0.12);
}

.form-control.error {
    border-color: var(--danger);
}

.form-error {
    font-size: 0.75rem;
    color: var(--danger);
    margin-top: 3px;
}

.form-hint {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 3px;
}

select.form-control {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%23757575' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

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

/* Cards */
.card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
    margin-bottom: 10px;
}

.stat-card {
    text-align: center;
    padding: 20px 14px;
}

.stat-value {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--primary);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-top: 4px;
}

/* List items */
.list-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    min-height: 56px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    margin-bottom: 6px;
    cursor: pointer;
    transition: background 0.15s;
}

.list-item:active {
    background: #F5F5F5;
}

.list-item-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.9rem;
    color: white;
    flex-shrink: 0;
}

.list-item-content {
    flex: 1;
    min-width: 0;
}

.list-item-title {
    font-weight: 600;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-subtitle {
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.list-item-right {
    text-align: right;
    flex-shrink: 0;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.badge-success { background: var(--success-light); color: var(--success); }
.badge-danger { background: var(--danger-light); color: var(--danger); }
.badge-warning { background: var(--warning-light); color: var(--warning); }
.badge-info { background: #E3F2FD; color: #1565C0; }
.badge-neutral { background: #EEEEEE; color: #616161; }

/* Bottom-sheet modal */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: flex-end;
    z-index: 200;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
}

.modal-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.modal {
    background: white;
    border-radius: 16px 16px 0 0;
    width: 100%;
    max-height: 90dvh;
    padding: 20px 16px;
    padding-bottom: calc(20px + var(--safe-bottom));
    transform: translateY(100%);
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.modal-overlay.active .modal {
    transform: translateY(0);
}

.modal-title {
    font-size: 1.1rem;
    font-weight: 700;
    margin-bottom: 16px;
}

.modal-handle {
    width: 36px;
    height: 4px;
    background: var(--border);
    border-radius: 2px;
    margin: 0 auto 12px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: calc(var(--topbar-height) + var(--safe-top) + 8px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 300;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    width: 90%;
    max-width: 400px;
}

.toast {
    padding: 12px 16px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    color: white;
    text-align: center;
    pointer-events: auto;
    animation: toastIn 0.3s ease;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--danger); }
.toast-warning { background: var(--warning); }
.toast-info { background: var(--primary); }

@keyframes toastIn {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Tabs */
.tabs {
    display: flex;
    background: var(--surface);
    border-radius: var(--radius);
    padding: 4px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
}

.tab {
    flex: 1;
    padding: 10px 8px;
    min-height: 44px;
    font-weight: 600;
    font-size: 0.85rem;
    border: none;
    background: none;
    color: var(--text-secondary);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s;
    font-family: inherit;
}

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

/* Home grid */
.home-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
}

.home-grid-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 16px 8px;
    min-height: 96px;
    cursor: pointer;
    transition: transform 0.1s;
}

.home-grid-item:active {
    transform: scale(0.97);
}

.home-grid-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
}

.home-grid-icon svg {
    width: 22px;
    height: 22px;
}

.home-grid-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text);
    text-align: center;
}

/* Search bar */
.search-bar {
    position: relative;
    margin-bottom: 12px;
}

.search-bar input {
    width: 100%;
    padding: 10px 14px 10px 40px;
    min-height: 44px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius);
    font-size: 16px;
    font-family: inherit;
    background: var(--surface);
    -webkit-appearance: none;
}

.search-bar input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-bar svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 20px;
    height: 20px;
    color: var(--text-secondary);
}

/* Filter chips */
.filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 8px;
}

.filter-chip {
    display: inline-flex;
    align-items: center;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1.5px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    font-family: inherit;
}

.filter-chip.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 12px;
    opacity: 0.3;
}

.empty-state p {
    font-size: 0.9rem;
    margin-top: 8px;
}

/* FAB (floating action button) */
.fab {
    position: fixed;
    bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    border: none;
    box-shadow: 0 4px 12px rgba(21,101,192,0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    cursor: pointer;
    transition: transform 0.15s;
}

.fab:active {
    transform: scale(0.93);
}

.fab svg {
    width: 24px;
    height: 24px;
}

/* Section headers */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
    margin-top: 16px;
}

.section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: 16px 0;
}

/* Loading spinner */
.spinner {
    width: 24px;
    height: 24px;
    border: 3px solid var(--border);
    border-top: 3px solid var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

/* Checkbox group (permissions, class assignments) */
.checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 8px 0;
}
.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    cursor: pointer;
    padding: 6px 4px;
    border-radius: 6px;
}
.checkbox-label:active {
    background: var(--bg-secondary);
}
.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

/* QR Code Cards */
.qr-card {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    text-align: center;
    break-inside: avoid;
}
.qr-card-school {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qr-card-image svg {
    width: 100%;
    max-width: 140px;
    height: auto;
}
.qr-card-name {
    font-size: 0.8rem;
    font-weight: 600;
    margin-top: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.qr-card-number {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

/* === Tuckshop / Inventory Dashboard Grid === */
.inv-dash-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.inv-dash-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 10px;
    text-align: center;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-height: 90px;
    justify-content: center;
}
.inv-dash-card:active {
    transform: scale(0.96);
    background: #F5F5F5;
}
.inv-dash-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary);
}
.inv-dash-value {
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--primary);
}
@media (max-width: 340px) {
    .inv-dash-grid { grid-template-columns: repeat(2, 1fr); }
}
.profit-warning {
    background: #FFF3E0;
    border-left: 4px solid var(--danger);
    padding: 10px 12px;
    border-radius: var(--radius);
    font-size: 0.85rem;
    color: var(--danger);
    font-weight: 600;
    margin-top: 8px;
}
