/* css/components.css */

/* Glass Card */
.glass-panel {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-glass);
    padding: 1.5rem;
    overflow: hidden;
    position: relative;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: var(--transition-fast);
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.96);
}

.btn-primary {
    background-color: var(--primary-color);
    color: #fff;
    box-shadow: 0 4px 14px 0 rgba(37, 99, 235, 0.39);
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 6px 20px rgba(37, 99, 235, 0.23);
}

.btn-outline {
    background-color: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
}

.btn-icon {
    padding: 0.5rem;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-surface);
    color: var(--text-primary);
    box-shadow: var(--shadow-sm);
}

.btn-block {
    width: 100%;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.input-label {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--text-secondary);
}

.input-field {
    width: 100%;
    padding: 0.75rem 1rem;
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    transition: var(--transition-fast);
    box-shadow: inset 0 1px 2px rgba(0, 0, 0, 0.05);
}

.input-field:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 70px;
    background: var(--bg-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-around;
    align-items: center;
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.25rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    transition: var(--transition-fast);
    cursor: pointer;
    flex: 1;
    height: 100%;
}

.nav-item svg {
    width: 24px;
    height: 24px;
    fill: currentColor;
    transition: transform var(--transition-bounce);
}

.nav-item.active {
    color: var(--primary-color);
}

.nav-item.active svg {
    transform: translateY(-2px);
}

/* Toast */
.toast-container {
    position: fixed;
    top: env(safe-area-inset-top, 20px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    width: 90%;
    max-width: 400px;
    pointer-events: none;
}

.toast {
    background: var(--bg-surface);
    color: var(--text-primary);
    padding: 1rem;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 0.75rem;
    pointer-events: auto;
    border-right: 4px solid var(--primary-color);
}

.toast.error { border-right-color: var(--danger-color); }
.toast.success { border-right-color: var(--secondary-color); }

/* Loader */
.loader-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100vh;
    gap: 1rem;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--border-glass);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Modals */
.modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 2000;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-normal);
}

.modal-backdrop.open {
    opacity: 1;
    pointer-events: auto;
}

.modal-window {
    background: var(--bg-surface);
    border-top: 1px solid var(--border-glass);
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.3);
    transform: translateY(100%);
    transition: transform var(--transition-bounce);
    overflow: hidden;
}

.modal-backdrop.open .modal-window {
    transform: translateY(0);
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    margin: 0;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--text-primary);
}

.modal-body {
    padding: 1.25rem 1.5rem;
    overflow-y: auto;
    flex: 1;
    -webkit-overflow-scrolling: touch;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-glass);
    background: var(--bg-glass);
    display: flex;
    gap: 0.75rem;
    justify-content: flex-end;
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.65rem;
    font-size: 0.75rem;
    font-weight: 700;
    border-radius: 9999px;
    white-space: nowrap;
}

.badge-primary { background: rgba(37, 99, 235, 0.15); color: #3b82f6; }
.badge-success { background: rgba(16, 185, 129, 0.15); color: #10b981; }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: #f59e0b; }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: #ef4444; }
.badge-neutral { background: rgba(148, 163, 184, 0.15); color: var(--text-secondary); }

/* Segmented Controls */
.segmented-group {
    display: flex;
    background: rgba(0, 0, 0, 0.06);
    border-radius: var(--radius-md);
    padding: 3px;
    gap: 2px;
    user-select: none;
}
[data-theme="dark"] .segmented-group {
    background: rgba(255, 255, 255, 0.06);
}

.segmented-btn {
    flex: 1;
    padding: 0.5rem 0.75rem;
    text-align: center;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: var(--transition-fast);
    border: none;
    background: transparent;
}

.segmented-btn.active {
    background: var(--bg-surface);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

/* Stepper */
.stepper {
    display: inline-flex;
    align-items: center;
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    background: var(--bg-surface);
    overflow: hidden;
}

.stepper-btn {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.stepper-btn:active {
    background: rgba(37, 99, 235, 0.15);
}

.stepper-value {
    width: 44px;
    height: 36px;
    text-align: center;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.95rem;
    -moz-appearance: textfield;
}

.stepper-value::-webkit-inner-spin-button,
.stepper-value::-webkit-outer-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* Summary Box */
.calc-box {
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.calc-row.total {
    font-size: 1.15rem;
    font-weight: 800;
    color: var(--text-primary);
    padding-top: 0.5rem;
    border-top: 1px dashed var(--border-glass);
}

/* Search Bar */
.search-bar-wrap {
    position: relative;
    width: 100%;
}

.search-bar-wrap .input-field {
    padding-inline-start: 2.75rem;
    padding-inline-end: 2.5rem;
}

.search-bar-icon {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-start: 0.85rem;
    color: var(--text-muted);
    pointer-events: none;
    display: flex;
}

.search-bar-clear {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    inset-inline-end: 0.75rem;
    color: var(--text-muted);
    background: transparent;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
}

/* Filter Chips */
.chips-scroll {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.chip {
    padding: 0.4rem 0.9rem;
    border-radius: 9999px;
    font-size: 0.825rem;
    font-weight: 600;
    background: var(--bg-glass);
    border: 1px solid var(--border-glass);
    color: var(--text-secondary);
    white-space: nowrap;
    cursor: pointer;
    transition: var(--transition-fast);
}

.chip.active {
    background: var(--primary-color);
    color: #fff;
    border-color: var(--primary-color);
}

/* Camera Scanner Overlay */
.scanner-container {
    position: fixed;
    inset: 0;
    background: #000;
    z-index: 3000;
    display: flex;
    flex-direction: column;
}

.scanner-video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.scanner-reticle-wrap {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.scanner-reticle {
    width: 260px;
    height: 260px;
    border: 2px solid rgba(255, 255, 255, 0.8);
    border-radius: 20px;
    position: relative;
    box-shadow: 0 0 0 4000px rgba(0, 0, 0, 0.55);
}

.scanner-laser {
    position: absolute;
    left: 10px;
    right: 10px;
    height: 3px;
    background: #ef4444;
    box-shadow: 0 0 8px #ef4444;
    border-radius: 2px;
    animation: scanLaser 2s ease-in-out infinite;
}

@keyframes scanLaser {
    0%, 100% { top: 15px; opacity: 0.3; }
    50% { top: 240px; opacity: 1; }
}

.scanner-top-bar {
    position: absolute;
    top: env(safe-area-inset-top, 20px);
    left: 1.5rem;
    right: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 3010;
}

.scanner-bottom-bar {
    position: absolute;
    bottom: env(safe-area-inset-bottom, 30px);
    left: 1.5rem;
    right: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    align-items: center;
    z-index: 3010;
}

/* Switch */
.switch-wrap {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
}

.switch-toggle {
    position: relative;
    width: 48px;
    height: 26px;
    appearance: none;
    background: rgba(148, 163, 184, 0.3);
    outline: none;
    border-radius: 13px;
    cursor: pointer;
    transition: var(--transition-fast);
}

.switch-toggle:checked {
    background: var(--primary-color);
}

.switch-toggle::before {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    top: 2px;
    inset-inline-start: 2px;
    background: #fff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    transition: var(--transition-fast);
}

.switch-toggle:checked::before {
    inset-inline-start: 24px;
}

/* Modern Dashboard Styles */
.glass-panel-modern {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.05);
    padding: 1.25rem;
    position: relative;
    overflow: hidden;
}

.btn-action-modern {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    background: transparent;
    border: none;
    padding: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-primary);
    border-radius: var(--radius-md);
    transition: transform var(--transition-bounce), opacity var(--transition-fast);
}

.btn-action-modern:active {
    transform: scale(0.92);
    opacity: 0.8;
}

.icon-wrap {
    width: 48px;
    height: 48px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 0.25rem;
}

.bg-primary-light { background: rgba(37, 99, 235, 0.1); }
.bg-success-light { background: rgba(16, 185, 129, 0.1); }
.bg-warning-light { background: rgba(245, 158, 11, 0.1); }
.bg-info-light { background: rgba(14, 165, 233, 0.1); }
.bg-danger-light { background: rgba(239, 68, 68, 0.1); }
.bg-secondary-light { background: rgba(100, 116, 139, 0.1); }

.text-info { color: #0ea5e9; }

.kpi-card {
    display: flex;
    flex-direction: column;
    padding: 1.25rem;
}
.kpi-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.kpi-icon {
    width: 32px;
    height: 32px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.invoice-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 0;
    border-bottom: 1px solid var(--border-glass);
    cursor: pointer;
    transition: background var(--transition-fast);
}
.invoice-list-item:last-child {
    border-bottom: none;
}
.invoice-list-item:active {
    background: rgba(0,0,0,0.02);
}

/* Floating Bottom Nav */
.floating-nav-wrapper {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 20px);
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    pointer-events: none;
    z-index: 1000;
    padding: 0 1rem;
}

.bottom-nav-floating {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background: var(--bg-surface);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--border-glass);
    border-radius: 9999px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    height: 64px;
    width: 100%;
    max-width: 400px;
    pointer-events: auto;
    padding: 0 0.5rem;
}

[data-theme="dark"] .bottom-nav-floating {
    background: rgba(30, 30, 30, 0.85);
    border-color: rgba(255, 255, 255, 0.08);
}

.bottom-nav-floating .nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    color: var(--text-muted);
    font-size: 0.7rem;
    font-weight: 600;
    transition: var(--transition-bounce);
    cursor: pointer;
    flex: 1;
    height: 100%;
    text-decoration: none;
}

.bottom-nav-floating .nav-item svg {
    transition: transform var(--transition-bounce), stroke var(--transition-fast);
}

.bottom-nav-floating .nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-floating .nav-item.active svg {
    transform: translateY(-3px);
    stroke-width: 2.5;
}

/* Floating Action Button (FAB) */
.fab-container {
    position: fixed;
    bottom: env(safe-area-inset-bottom, 90px);
    right: 1.5rem;
    z-index: 1010;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
}

.fab-menu {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1rem;
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.4);
    border-radius: 16px;
    padding: 0.5rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    transform-origin: bottom right;
}

[data-theme="dark"] .fab-menu {
    background: rgba(30, 30, 30, 0.95);
    border-color: rgba(255, 255, 255, 0.1);
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.fab-menu.show {
    opacity: 1;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

.fab-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 0.85rem;
    font-weight: 600;
    border-radius: 12px;
    cursor: pointer;
    transition: var(--transition-fast);
    text-align: right;
    width: 100%;
}

.fab-menu-item:hover, .fab-menu-item:active {
    background: rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] .fab-menu-item:hover, [data-theme="dark"] .fab-menu-item:active {
    background: rgba(255, 255, 255, 0.05);
}

.fab-menu-icon {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--bg-surface);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
    color: var(--primary-color);
}

.fab-button {
    background: linear-gradient(135deg, #3b82f6, #1d4ed8);
    color: white;
    border: none;
    border-radius: 9999px;
    padding: 0.75rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    box-shadow: 0 10px 25px rgba(37, 99, 235, 0.4);
    cursor: pointer;
    transition: transform var(--transition-bounce), box-shadow var(--transition-fast);
}

.fab-button:active {
    transform: scale(0.95);
    box-shadow: 0 5px 15px rgba(37, 99, 235, 0.3);
}

.fab-button svg {
    transition: transform 0.3s ease;
}

.fab-container.open .fab-button svg {
    transform: rotate(45deg);
}

/* Dashboard Mockup Charts */
.chart-container {
    position: relative;
    height: 180px;
    width: 100%;
    margin-top: 1rem;
}
