/* =============================================
   PWA Control Total Lavadoras - Styles
   ============================================= */

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --success: #16a34a;
    --success-light: #dcfce7;
    --danger: #dc2626;
    --danger-light: #fee2e2;
    --warning: #f59e0b;
    --warning-light: #fef3c7;
    --info: #0891b2;
    --info-light: #cffafe;
    --dark: #1a1a2e;
    --dark-2: #16213e;
    --dark-3: #0f3460;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --text: #1f2937;
    --text-light: #6b7280;
    --bg: #f0f2f5;
    --card-bg: #ffffff;
    --shadow: 0 1px 3px rgba(0,0,0,0.12), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
    --radius: 12px;
    --radius-sm: 8px;
    --header-h: 56px;
    --bottom-nav-h: 60px;
    --transition: 0.2s ease;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.5;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.hidden { display: none !important; }

/* ========== LOGIN ========== */
.screen { min-height: 100vh; }

#login-screen {
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, var(--dark) 0%, var(--dark-2) 50%, var(--dark-3) 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 380px;
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
    color: #fff;
}

.logo-icon {
    font-size: 48px;
    margin-bottom: 12px;
}

.login-logo h1 {
    font-size: 24px;
    font-weight: 700;
    line-height: 1.3;
}

.login-logo p {
    color: var(--gray-400);
    font-size: 14px;
    margin-top: 4px;
}

#login-form {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
}

.form-group {
    margin-bottom: 16px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--gray-600);
    margin-bottom: 6px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 15px;
    color: var(--text);
    background: var(--gray-50);
    transition: border-color var(--transition);
    outline: none;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    background: #fff;
}

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.error-msg {
    color: var(--danger);
    font-size: 13px;
    margin-top: 12px;
    text-align: center;
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #15803d; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-warning { background: var(--warning); color: #fff; }
.btn-warning:hover { background: #d97706; }
.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--text);
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-block { width: 100%; }
.btn-icon {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 20px;
    color: inherit;
    padding: 4px;
    line-height: 1;
}

.btn-action {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    padding: 0;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-whatsapp { background: #25d366; color: #fff; }
.btn-whatsapp:hover { background: #1da851; }
.btn-map { background: var(--info); color: #fff; }
.btn-map:hover { background: #0e7490; }
.btn-time-free { background: var(--success); color: #fff; }
.btn-time-free:hover { background: #15803d; }
.btn-time-paid { background: var(--warning); color: #fff; }
.btn-time-paid:hover { background: #d97706; }

/* ========== HEADER ========== */
.app-header {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-h);
    background: var(--dark-2);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 100;
    box-shadow: var(--shadow-md);
}

.header-left, .header-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-left h2 { font-size: 17px; font-weight: 600; }

.user-badge {
    font-size: 12px;
    background: var(--dark-3);
    padding: 4px 10px;
    border-radius: 20px;
}

/* ========== SIDEBAR ========== */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background: var(--dark);
    color: #fff;
    z-index: 200;
    transition: left 0.3s ease;
    overflow-y: auto;
}

.sidebar.open { left: 0; }

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-header h3 { font-size: 16px; }

.nav-list {
    list-style: none;
    padding: 8px 0;
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: var(--gray-400);
    text-decoration: none;
    font-size: 15px;
    transition: all var(--transition);
}

.nav-link:hover, .nav-link.active {
    color: #fff;
    background: rgba(255,255,255,0.08);
}

.nav-link.active { border-left: 3px solid var(--primary); }

.nav-icon { font-size: 18px; width: 24px; text-align: center; }

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 199;
}

.sidebar-overlay.show { display: block; }

/* ========== MAIN CONTENT ========== */
.main-content {
    margin-top: var(--header-h);
    padding: 16px;
    padding-bottom: calc(var(--bottom-nav-h) + 20px);
    min-height: calc(100vh - var(--header-h));
}

/* ========== BOTTOM NAV ========== */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: var(--bottom-nav-h);
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: space-around;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 100;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    text-decoration: none;
    color: var(--gray-400);
    font-size: 11px;
    font-weight: 500;
    padding: 4px 8px;
    transition: color var(--transition);
}

.bottom-nav-item.active { color: var(--primary); }
.bottom-icon { font-size: 22px; }

/* ========== CARDS ========== */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
}

.card-header {
    padding: 14px 16px;
    border-bottom: 1px solid var(--gray-100);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 { font-size: 15px; font-weight: 600; }

.card-body { padding: 16px; }

/* ========== COUNTER CARDS (Dashboard) ========== */
.counters-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.counter-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    text-align: center;
    box-shadow: var(--shadow);
    position: relative;
    overflow: hidden;
}

.counter-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
}

.counter-card.working::before { background: var(--primary); }
.counter-card.available::before { background: var(--success); }
.counter-card.unpaid::before { background: var(--danger); }
.counter-card.scheduled::before { background: var(--warning); }

.counter-number {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 4px;
}

.counter-card.working .counter-number { color: var(--primary); }
.counter-card.available .counter-number { color: var(--success); }
.counter-card.unpaid .counter-number { color: var(--danger); }
.counter-card.scheduled .counter-number { color: var(--warning); }

.counter-label {
    font-size: 12px;
    color: var(--text-light);
    font-weight: 500;
}

/* ========== MACHINE CARDS (Working) ========== */
.machine-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--primary);
}

.machine-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.machine-code {
    font-weight: 700;
    font-size: 15px;
    color: var(--dark);
}

.machine-timer {
    font-size: 22px;
    font-weight: 700;
    font-variant-numeric: tabular-nums;
    color: var(--primary);
    letter-spacing: 1px;
}

.machine-timer.expired { color: var(--danger); }

.machine-info {
    font-size: 13px;
    color: var(--text-light);
    margin-bottom: 10px;
}

.machine-info .client-name {
    font-weight: 600;
    color: var(--text);
}

.machine-actions {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
}

/* ========== UNPAID LIST ========== */
.unpaid-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

.unpaid-item:last-child { border-bottom: none; }

.unpaid-info h4 {
    font-size: 14px;
    font-weight: 600;
}

.unpaid-info p {
    font-size: 12px;
    color: var(--text-light);
}

.unpaid-amount {
    font-weight: 700;
    color: var(--danger);
    font-size: 15px;
}

/* ========== DATA TABLE ========== */
.data-list { list-style: none; }

.data-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    transition: background var(--transition);
}

.data-item:hover { background: var(--gray-50); }
.data-item:last-child { border-bottom: none; }

.data-item-info h4 { font-size: 14px; font-weight: 600; }
.data-item-info p { font-size: 12px; color: var(--text-light); margin-top: 2px; }

.data-item-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* ========== BADGE / TAG ========== */
.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
}

.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: var(--info-light); color: var(--info); }
.badge-primary { background: var(--primary-light); color: var(--primary); }

/* ========== STATUS DOT ========== */
.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 6px;
}

.status-dot.available { background: var(--success); }
.status-dot.working { background: var(--primary); animation: pulse 2s infinite; }
.status-dot.maintenance { background: var(--warning); }

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* ========== MODAL ========== */
.modal {
    position: fixed;
    inset: 0;
    z-index: 300;
    display: flex;
    align-items: flex-end;
    justify-content: center;
}

.modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.5);
}

.modal-content {
    position: relative;
    background: var(--card-bg);
    border-radius: var(--radius) var(--radius) 0 0;
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(100%); }
    to { transform: translateY(0); }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    background: var(--card-bg);
    z-index: 1;
}

.modal-header h3 { font-size: 17px; font-weight: 700; }

.modal-body { padding: 20px; }

.modal-body .form-group:last-child { margin-bottom: 0; }

.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

.modal-actions .btn { flex: 1; }

/* ========== TOAST ========== */
.toast-container {
    position: fixed;
    top: calc(var(--header-h) + 12px);
    right: 12px;
    z-index: 400;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: var(--dark);
    color: #fff;
    padding: 12px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    box-shadow: var(--shadow-lg);
    animation: toastIn 0.3s ease;
    max-width: 320px;
}

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

@keyframes toastIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* ========== SEARCH BAR ========== */
.search-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.search-bar input {
    flex: 1;
    padding: 10px 14px;
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    font-size: 14px;
    background: #fff;
    outline: none;
}

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

/* ========== SECTION TITLE ========== */
.section-title {
    font-size: 16px;
    font-weight: 700;
    color: var(--text);
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* ========== STATS ROW ========== */
.stats-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 16px;
    box-shadow: var(--shadow);
}

.stat-label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 4px;
}

.stat-value {
    font-size: 20px;
    font-weight: 700;
}

.stat-value.positive { color: var(--success); }
.stat-value.negative { color: var(--danger); }

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-light);
}

.empty-state .empty-icon {
    font-size: 48px;
    margin-bottom: 12px;
    opacity: 0.5;
}

.empty-state p { font-size: 14px; }

/* ========== LOADING ========== */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 36px;
    height: 36px;
    border: 3px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* ========== TABS ========== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    background: var(--gray-100);
    border-radius: var(--radius-sm);
    padding: 3px;
    overflow-x: auto;
}

.tab {
    flex: 1;
    padding: 8px 14px;
    border: none;
    background: none;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-light);
    cursor: pointer;
    border-radius: 6px;
    white-space: nowrap;
    transition: all var(--transition);
}

.tab.active {
    background: #fff;
    color: var(--primary);
    box-shadow: var(--shadow);
}

/* ========== WEEK HEADER ========== */
.week-header {
    text-align: center;
    padding: 8px;
    margin-bottom: 16px;
    color: var(--text-light);
    font-size: 14px;
    font-weight: 500;
}

.week-header strong {
    color: var(--text);
}

/* ========== EXPENSE CATEGORY ICONS ========== */
.expense-cat {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 600;
    text-transform: capitalize;
}

/* ========== REPORT TABLE ========== */
.report-summary {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 20px;
}

.report-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 14px;
    box-shadow: var(--shadow);
}

.report-item.full-width {
    grid-column: span 2;
}

.report-item .label {
    font-size: 12px;
    color: var(--text-light);
    margin-bottom: 2px;
}

.report-item .value {
    font-size: 22px;
    font-weight: 700;
}

/* ========== RESPONSIVE ========== */
@media (min-width: 768px) {
    .main-content {
        max-width: 600px;
        margin-left: auto;
        margin-right: auto;
    }

    .counters-grid {
        grid-template-columns: repeat(4, 1fr);
    }

    .modal {
        align-items: center;
    }

    .modal-content {
        border-radius: var(--radius);
        max-width: 500px;
    }
}

/* ========== SCHEDULED ITEM ========== */
.scheduled-item {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 14px 16px;
    margin-bottom: 12px;
    border-left: 4px solid var(--warning);
}

.scheduled-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.scheduled-date {
    font-size: 13px;
    font-weight: 600;
    color: var(--warning);
}

.scheduled-info {
    font-size: 13px;
    color: var(--text-light);
}

.scheduled-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

/* ========== FAB (Floating Action Button) ========== */
.fab {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 16px);
    right: 16px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    border: none;
    font-size: 28px;
    cursor: pointer;
    box-shadow: var(--shadow-lg);
    z-index: 50;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
}

.fab:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

/* ========== DATE NAVIGATION ========== */
.date-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    margin-bottom: 16px;
}

.date-nav button {
    background: var(--card-bg);
    border: 1.5px solid var(--gray-200);
    border-radius: var(--radius-sm);
    padding: 8px 14px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 600;
    transition: all var(--transition);
}

.date-nav button:hover {
    border-color: var(--primary);
    color: var(--primary);
}

.date-nav span {
    font-weight: 600;
    font-size: 14px;
    min-width: 180px;
    text-align: center;
}

/* ========== PWA INSTALL BANNER ========== */
.install-banner {
    position: fixed;
    bottom: calc(var(--bottom-nav-h) + 8px);
    left: 12px;
    right: 12px;
    z-index: 90;
    animation: slideUp 0.4s ease;
}

.install-banner-content {
    background: var(--dark-2);
    color: #fff;
    border-radius: var(--radius);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    box-shadow: var(--shadow-lg);
}

.install-banner-icon {
    font-size: 28px;
    flex-shrink: 0;
}

.install-banner-text {
    flex: 1;
    min-width: 0;
}

.install-banner-text strong {
    font-size: 14px;
    display: block;
}

.install-banner-text p {
    font-size: 11px;
    color: var(--gray-400);
    margin: 0;
}

/* ========== MAP PICKER ========== */
.map-container {
    width: 100%;
    height: 250px;
    border-radius: var(--radius-sm);
    border: 1.5px solid var(--gray-200);
    margin-top: 8px;
    overflow: hidden;
}

.map-container .leaflet-container {
    height: 100%;
    width: 100%;
}

.address-with-map {
    position: relative;
}

.address-with-map .btn-map-toggle {
    position: absolute;
    right: 8px;
    top: 32px;
    background: var(--info);
    color: #fff;
    border: none;
    border-radius: 6px;
    padding: 6px 10px;
    font-size: 12px;
    cursor: pointer;
    z-index: 1;
}

.map-hint {
    font-size: 11px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ========== INLINE NEW CLIENT ========== */
.inline-client-form {
    background: var(--gray-50);
    border: 1.5px dashed var(--gray-300);
    border-radius: var(--radius-sm);
    padding: 12px;
    margin-top: 8px;
}

.inline-client-form h4 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 10px;
    color: var(--primary);
}

.client-select-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.client-select-row select {
    flex: 1;
}

.client-select-row .btn {
    flex-shrink: 0;
    height: 40px;
}
