/* ============================================
   VetSaaS — Sistema de Gestão Veterinária
   ============================================ */

:root {
    --primary: #0F172A;
    --primary-light: #1E293B;
    --accent: #3B82F6;
    --accent-hover: #2563EB;
    --accent-light: #DBEAFE;
    --success: #10B981;
    --success-light: #D1FAE5;
    --warning: #F59E0B;
    --warning-light: #FEF3C7;
    --danger: #EF4444;
    --danger-light: #FEE2E2;
    --bg: #F8FAFC;
    --card: #FFFFFF;
    --border: #E2E8F0;
    --text: #1E293B;
    --text-light: #64748B;
    --text-muted: #94A3B8;
    --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: var(--accent-hover); }

/* ── Layout ─────────────────────────────── */

.layout {
    display: flex;
    min-height: 100vh;
}

/* ── Sidebar ────────────────────────────── */

.sidebar {
    width: 260px;
    background: var(--primary);
    color: #CBD5E1;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-brand {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand h1 {
    font-size: 18px;
    font-weight: 700;
    color: #FFFFFF;
    letter-spacing: -0.5px;
}

.sidebar-brand p {
    font-size: 12px;
    color: #93C5FD;
    margin-top: 2px;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 20px;
    color: #CBD5E1;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: rgba(255,255,255,0.08);
    color: #FFFFFF;
}

.sidebar-nav a.active {
    background: rgba(59,130,246,0.15);
    color: #93C5FD;
    border-left-color: var(--accent);
}

.sidebar-nav a .icon {
    width: 20px;
    text-align: center;
    font-size: 16px;
}

.sidebar-nav .nav-section {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748B;
    padding: 16px 20px 8px;
}

.sidebar-user {
    padding: 16px 20px;
    border-top: 1px solid rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.sidebar-user .avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 14px;
}

.sidebar-user .info { flex: 1; }
.sidebar-user .info .name { font-size: 13px; color: #FFFFFF; font-weight: 500; }
.sidebar-user .info .clinic { font-size: 11px; color: #94A3B8; }

/* ── Main Content ───────────────────────── */

.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 24px 32px;
    min-height: 100vh;
}

/* ── Page Header ────────────────────────── */

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 12px;
}

.page-header h2 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.page-header .subtitle {
    font-size: 14px;
    color: var(--text-light);
}

/* ── Cards ──────────────────────────────── */

.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 24px;
}

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

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    color: var(--primary);
}

/* ── Stats Grid ─────────────────────────── */

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px 24px;
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
}

.stat-card .stat-icon.blue { background: var(--accent-light); }
.stat-card .stat-icon.green { background: var(--success-light); }
.stat-card .stat-icon.amber { background: var(--warning-light); }
.stat-card .stat-icon.red { background: var(--danger-light); }

.stat-card .stat-info .number {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
    line-height: 1;
}

.stat-card .stat-info .label {
    font-size: 13px;
    color: var(--text-light);
    margin-top: 4px;
}

/* ── Tables ─────────────────────────────── */

.table-wrapper {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
}

table th {
    background: #F1F5F9;
    padding: 12px 16px;
    text-align: left;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-light);
    border-bottom: 2px solid var(--border);
    white-space: nowrap;
}

table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    font-size: 14px;
    color: var(--text);
}

table tr:hover { background: #F8FAFC; }

table .text-right { text-align: right; }
table .text-center { text-align: center; }

.table-empty {
    text-align: center;
    padding: 40px 20px;
    color: var(--text-muted);
    font-size: 14px;
}

/* ── Buttons ────────────────────────────── */

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    font-weight: 500;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    line-height: 1.4;
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); color: white; }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #059669; color: white; }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #D97706; color: white; }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #DC2626; color: white; }

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text);
}
.btn-outline:hover {
    background: #F1F5F9;
    border-color: #CBD5E1;
    color: var(--text);
}

.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-xs { padding: 4px 8px; font-size: 12px; }

/* ── Forms ──────────────────────────────── */

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

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

.form-group .hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 4px;
}

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    color: var(--text);
    background: #FFFFFF;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

select.form-control {
    appearance: auto;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
}

.form-inline {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ── Alerts / Flash Messages ────────────── */

.alerts {
    margin-bottom: 20px;
}

.alert {
    padding: 14px 20px;
    border-radius: var(--radius);
    font-size: 14px;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success { background: var(--success-light); color: #065F46; border: 1px solid #A7F3D0; }
.alert-error { background: var(--danger-light); color: #991B1B; border: 1px solid #FECACA; }
.alert-warning { background: var(--warning-light); color: #92400E; border: 1px solid #FDE68A; }
.alert-info { background: var(--accent-light); color: #1E40AF; border: 1px solid #BFDBFE; }

/* ── Badges ─────────────────────────────── */

.badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 999px;
    font-size: 12px;
    font-weight: 600;
}

.badge-blue { background: var(--accent-light); color: #1E40AF; }
.badge-green { background: var(--success-light); color: #065F46; }
.badge-amber { background: var(--warning-light); color: #92400E; }
.badge-red { background: var(--danger-light); color: #991B1B; }
.badge-gray { background: #F1F5F9; color: #475569; }

/* ── Search / Filter Bar ────────────────── */

.filter-bar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-bar .search-input {
    flex: 1;
    min-width: 200px;
    padding: 10px 14px 10px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: white url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E") 12px center no-repeat;
}

.filter-bar .search-input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(59,130,246,0.15);
}

.filter-bar select {
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: white;
    color: var(--text);
}

/* ── Calculator specific ────────────────── */

.calc-result {
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    color: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    margin-top: 20px;
}

.calc-result h3 {
    font-size: 14px;
    font-weight: 600;
    color: #93C5FD;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 16px;
}

.calc-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
}

.calc-row:last-child { border-bottom: none; }

.calc-row .label { color: #CBD5E1; }
.calc-row .value { font-weight: 600; color: #FFFFFF; }

.calc-row.total {
    margin-top: 12px;
    padding-top: 16px;
    border-top: 2px solid rgba(59,130,246,0.5);
    border-bottom: none;
    font-size: 20px;
}

.calc-row.total .value { color: #93C5FD; }

/* ── Price status colors ────────────────── */

.price-ok { color: var(--success); }
.price-low { color: var(--warning); }
.price-danger { color: var(--danger); font-weight: 600; }

/* ── Auth Pages ─────────────────────────── */

.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0F172A 0%, #1E293B 50%, #0F172A 100%);
    padding: 20px;
}

.auth-card {
    background: var(--card);
    border-radius: var(--radius-lg);
    box-shadow: 0 25px 50px rgba(0,0,0,0.25);
    width: 100%;
    max-width: 460px;
    padding: 40px;
}

.auth-card .brand {
    text-align: center;
    margin-bottom: 32px;
}

.auth-card .brand h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--primary);
}

.auth-card .brand p {
    font-size: 14px;
    color: var(--text-light);
    margin-top: 4px;
}

.auth-card .form-group { margin-bottom: 20px; }

.auth-card .btn-primary {
    width: 100%;
    padding: 12px;
    font-size: 15px;
    font-weight: 600;
    justify-content: center;
}

.auth-footer {
    text-align: center;
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-light);
}

/* ── Mobile Sidebar Toggle ──────────────── */

.sidebar-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 200;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--accent);
    color: white;
    border: none;
    font-size: 20px;
    cursor: pointer;
    box-shadow: var(--shadow-md);
    align-items: center;
    justify-content: center;
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .main-content {
        margin-left: 0;
        padding: 16px;
    }
    .sidebar-toggle {
        display: flex;
    }
    .page-header h2 {
        font-size: 20px;
    }
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    .form-row {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
}

/* ── Utilities ──────────────────────────── */

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.d-flex { display: flex; }
.gap-2 { gap: 16px; }
.align-center { align-items: center; }
.justify-between { justify-content: space-between; }
.w-full { width: 100%; }
.hidden { display: none; }
