/* =========================================
   PsicoGestão - Sistema de Gestão Psicológica
   CSS Principal - Design Premium
   ========================================= */

/* ------ RESET & BASE ------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
    --menu-color: #1e3a5f;
    --bg-color: #f0f4f8;
    --sidebar-width: 260px;
    --topbar-height: 64px;

    /* Paleta */
    --primary:       #2563eb;
    --primary-dark:  #1d4ed8;
    --primary-light: #dbeafe;
    --secondary:     #7c3aed;
    --success:       #059669;
    --danger:        #dc2626;
    --warning:       #d97706;
    --info:          #0891b2;
    --text-dark:     #0f172a;
    --text-mid:      #475569;
    --text-light:    #94a3b8;
    --border:        #e2e8f0;
    --card-bg:       #ffffff;
    --shadow-sm:     0 1px 3px rgba(0,0,0,.08);
    --shadow-md:     0 4px 16px rgba(0,0,0,.10);
    --shadow-lg:     0 10px 40px rgba(0,0,0,.14);
    --radius-sm:     8px;
    --radius-md:     12px;
    --radius-lg:     16px;
    --radius-xl:     24px;
    --transition:    all .2s ease;
}

html { font-size: 16px; scroll-behavior: smooth; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    color: var(--text-dark);
    min-height: 100vh;
    background-color: var(--bg-color);
    display: flex;
    overflow-x: hidden;
}

a { text-decoration: none; color: inherit; }
table { border-collapse: collapse; width: 100%; }
img { max-width: 100%; }

/* ------ SIDEBAR ------ */
.sidebar {
    width: var(--sidebar-width);
    background: var(--menu-color);
    min-height: 100vh;
    position: fixed;
    left: 0; top: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform .3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,.15);
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid rgba(255,255,255,.1);
    min-height: 80px;
    display: flex;
    align-items: center;
}

.sidebar-logo {
    max-height: 50px;
    max-width: 180px;
    object-fit: contain;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 12px;
    color: white;
    font-size: 1.1rem;
    font-weight: 700;
}

.sidebar-brand i {
    font-size: 1.5rem;
    color: #60a5fa;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,.75);
    font-size: .875rem;
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 2px;
}

.nav-item:hover {
    background: rgba(255,255,255,.12);
    color: white;
    transform: translateX(2px);
}

.nav-item.active {
    background: rgba(255,255,255,.18);
    color: white;
    box-shadow: inset 3px 0 0 #60a5fa;
}

.nav-item i { width: 18px; text-align: center; font-size: .95rem; }

.nav-divider {
    height: 1px;
    background: rgba(255,255,255,.1);
    margin: 12px 0;
}

.nav-section-label {
    display: block;
    font-size: .7rem;
    font-weight: 700;
    color: rgba(255,255,255,.4);
    text-transform: uppercase;
    letter-spacing: .1em;
    padding: 4px 14px 8px;
}

.sidebar-footer {
    padding: 16px 12px;
    border-top: 1px solid rgba(255,255,255,.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.user-avatar {
    width: 38px; height: 38px;
    border-radius: 50%;
    background: linear-gradient(135deg, #60a5fa, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: .9rem;
    flex-shrink: 0;
}

.user-details {
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
}

.user-name {
    color: white;
    font-size: .875rem;
    font-weight: 600;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: .65rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 100px;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.badge-role-master   { background: #fbbf24; color: #78350f; }
.badge-role-professional { background: #34d399; color: #064e3b; }
.badge-role-patient  { background: #a78bfa; color: #2e1065; }

.sidebar-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 34px; height: 34px;
    border-radius: var(--radius-sm);
    background: rgba(255,255,255,.1);
    color: rgba(255,255,255,.7);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: .85rem;
    transition: var(--transition);
    cursor: pointer;
    border: none;
}

.btn-icon:hover { background: rgba(255,255,255,.2); color: white; }
.btn-logout:hover { background: rgba(220,38,38,.4); color: #fca5a5; }

/* ------ MAIN CONTENT ------ */
.main-content {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

/* ------ TOPBAR ------ */
.topbar {
    height: var(--topbar-height);
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--text-mid);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--radius-sm);
    transition: var(--transition);
}

.menu-toggle:hover { background: var(--border); }

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.topbar-date {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--text-mid);
    font-size: .875rem;
}

.topbar-date i { color: var(--primary); }

.topbar-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 700;
    font-size: .85rem;
    cursor: pointer;
    transition: var(--transition);
}

.topbar-avatar:hover { transform: scale(1.05); box-shadow: 0 0 0 3px rgba(37,99,235,.2); }

/* ------ PAGE CONTENT ------ */
.page-content { padding: 24px; flex: 1; }

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

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 10px;
}

.page-title i { color: var(--primary); font-size: 1.3rem; }

/* ------ CARDS ------ */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    padding: 20px;
    border: 1px solid var(--border);
}

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

.card-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title i { color: var(--primary); }

/* ------ STAT CARDS ------ */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: white;
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card::before {
    content: '';
    position: absolute;
    top: 0; left: 0;
    width: 4px;
    height: 100%;
    background: var(--stat-color, var(--primary));
}

.stat-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.stat-icon {
    width: 52px; height: 52px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
    flex-shrink: 0;
}

.stat-body {}

.stat-value {
    font-size: 1.75rem;
    font-weight: 800;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: .8rem;
    color: var(--text-light);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: .05em;
}

/* Variações de cor stat */
.stat-blue   { --stat-color: #2563eb; }
.stat-green  { --stat-color: #059669; }
.stat-purple { --stat-color: #7c3aed; }
.stat-orange { --stat-color: #d97706; }
.stat-blue   .stat-icon { background: #dbeafe; color: #2563eb; }
.stat-green  .stat-icon { background: #d1fae5; color: #059669; }
.stat-purple .stat-icon { background: #ede9fe; color: #7c3aed; }
.stat-orange .stat-icon { background: #fef3c7; color: #d97706; }
.stat-blue   .stat-value { color: #2563eb; }
.stat-green  .stat-value { color: #059669; }
.stat-purple .stat-value { color: #7c3aed; }
.stat-orange .stat-value { color: #d97706; }

/* ------ BUTTONS ------ */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .875rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    white-space: nowrap;
}

.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); box-shadow: 0 4px 12px rgba(37,99,235,.35); transform: translateY(-1px); }

.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #047857; box-shadow: 0 4px 12px rgba(5,150,105,.35); transform: translateY(-1px); }

.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: #b91c1c; box-shadow: 0 4px 12px rgba(220,38,38,.35); transform: translateY(-1px); }

.btn-warning { background: var(--warning); color: white; }
.btn-warning:hover { background: #b45309; transform: translateY(-1px); }

.btn-secondary { background: var(--border); color: var(--text-dark); }
.btn-secondary:hover { background: #cbd5e1; transform: translateY(-1px); }

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary-light); }

.btn-sm { padding: 6px 12px; font-size: .8rem; }
.btn-lg { padding: 12px 24px; font-size: 1rem; }

/* ------ FORMS ------ */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: .85rem;
    font-weight: 600;
    color: var(--text-dark);
    margin-bottom: 6px;
}

.form-label .required { color: var(--danger); margin-left: 2px; }

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    color: var(--text-dark);
    background: white;
    transition: var(--transition);
    font-family: inherit;
    outline: none;
    appearance: none;
}

.form-control:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(37,99,235,.12);
}

select.form-control { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath fill='%2394a3b8' d='M7 7l3-3 3 3M7 13l3 3 3-3'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; background-size: 16px; padding-right: 40px; }

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

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

/* ------ TABLES ------ */
.table-wrapper {
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    overflow: hidden;
    background: white;
    box-shadow: var(--shadow-sm);
}

.data-table { width: 100%; }

.data-table thead { background: #f8fafc; }

.data-table th {
    padding: 12px 16px;
    text-align: left;
    font-size: .75rem;
    font-weight: 700;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: .06em;
    border-bottom: 1px solid var(--border);
}

.data-table td {
    padding: 13px 16px;
    font-size: .875rem;
    color: var(--text-dark);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: #f8fafc; }

/* ------ BADGES ------ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 100px;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .05em;
}

.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger  { background: #fee2e2; color: #991b1b; }
.badge-warning { background: #fef3c7; color: #92400e; }
.badge-info    { background: #e0f2fe; color: #075985; }
.badge-primary { background: #dbeafe; color: #1e40af; }
.badge-secondary { background: #f1f5f9; color: #475569; }
.badge-purple  { background: #ede9fe; color: #5b21b6; }

/* ------ ALERTS ------ */
.alert {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    border-radius: var(--radius-sm);
    margin: 0 24px 0;
    font-size: .875rem;
    font-weight: 500;
    position: relative;
    animation: slideDown .3s ease;
}

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

.alert-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.alert-danger  { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

.alert-close {
    position: absolute;
    right: 12px;
    background: none;
    border: none;
    cursor: pointer;
    color: inherit;
    opacity: .6;
    padding: 4px;
    transition: var(--transition);
}

.alert-close:hover { opacity: 1; }

/* ------ SEARCH BAR ------ */
.search-bar {
    display: flex;
    align-items: center;
    background: white;
    border: 1.5px solid var(--border);
    border-radius: var(--radius-sm);
    overflow: hidden;
    transition: var(--transition);
    flex: 1;
    max-width: 380px;
}

.search-bar:focus-within { border-color: var(--primary); box-shadow: 0 0 0 3px rgba(37,99,235,.1); }

.search-bar i {
    padding: 0 14px;
    color: var(--text-light);
    font-size: .9rem;
}

.search-bar input {
    border: none;
    outline: none;
    padding: 9px 0;
    font-size: .875rem;
    flex: 1;
    color: var(--text-dark);
    font-family: inherit;
    background: transparent;
}

/* ------ SCHEDULE CARDS ------ */
.schedule-day { margin-bottom: 20px; }

.schedule-day-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.schedule-day-date {
    font-size: .8rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: .06em;
}

.schedule-items { display: flex; flex-direction: column; gap: 8px; }

.schedule-item {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: var(--transition);
}

.schedule-item:hover { border-color: var(--primary); box-shadow: var(--shadow-sm); }

.schedule-time {
    font-weight: 700;
    font-size: .85rem;
    color: var(--primary);
    min-width: 48px;
}

.schedule-name {
    font-weight: 500;
    font-size: .875rem;
    flex: 1;
}

/* Status badges agenda */
.status-agendado  { background: #dbeafe; color: #1e40af; }
.status-confirmado{ background: #d1fae5; color: #065f46; }
.status-cancelado { background: #fee2e2; color: #991b1b; }
.status-realizado { background: #f1f5f9; color: #475569; }

/* ------ WHATSAPP BUTTON ------ */
.btn-whatsapp {
    background: #25d366;
    color: white;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: .8rem;
    font-weight: 600;
    transition: var(--transition);
    border: none;
    cursor: pointer;
}

.btn-whatsapp:hover { background: #128c7e; transform: scale(1.02); }

/* ------ OVERLAY MOBILE ------ */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 999;
}

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

.empty-state i {
    font-size: 3rem;
    margin-bottom: 12px;
    display: block;
    color: var(--border);
}

.empty-state h3 { font-size: 1rem; color: var(--text-mid); margin-bottom: 6px; }
.empty-state p { font-size: .875rem; }

/* ------ MODAL ------ */
.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay.active { display: flex; }

.modal {
    background: white;
    border-radius: var(--radius-lg);
    padding: 28px;
    max-width: 500px;
    width: 100%;
    box-shadow: var(--shadow-lg);
    animation: modalIn .25s ease;
}

@keyframes modalIn {
    from { opacity: 0; transform: scale(.95); }
    to { opacity: 1; transform: scale(1); }
}

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

.modal-title { font-size: 1.1rem; font-weight: 700; }
.modal-close { background: none; border: none; cursor: pointer; color: var(--text-light); font-size: 1.2rem; padding: 4px; }
.modal-close:hover { color: var(--danger); }

/* ------ SECTION DIVIDER ------ */
.section-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 24px 0 18px;
}

.section-divider span {
    font-size: .8rem;
    font-weight: 700;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
}

.section-divider::before,
.section-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: var(--border);
}

/* ------ RESPONSIVE ------ */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

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

    .main-content { margin-left: 0; }

    .menu-toggle { display: flex; }

    .page-content { padding: 16px; }

    .stats-grid { grid-template-columns: 1fr 1fr; }

    .form-grid-2 { grid-template-columns: 1fr; }
    .form-grid-3 { grid-template-columns: 1fr; }

    .topbar-date { display: none; }

    .page-header { flex-direction: column; align-items: flex-start; }
}

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

/* ------ LOGIN PAGE ------ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #0f172a 0%, #1e3a5f 50%, #312e81 100%);
    padding: 20px;
    position: relative;
    overflow: hidden;
}

.login-page::before {
    content: '';
    position: absolute;
    width: 600px; height: 600px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(37,99,235,.2), transparent 70%);
    top: -200px; right: -200px;
    pointer-events: none;
}

.login-page::after {
    content: '';
    position: absolute;
    width: 400px; height: 400px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(124,58,237,.2), transparent 70%);
    bottom: -100px; left: -100px;
    pointer-events: none;
}

.login-card {
    background: rgba(255,255,255,.05);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: var(--radius-xl);
    padding: 40px;
    max-width: 420px;
    width: 100%;
    position: relative;
    z-index: 1;
    box-shadow: 0 25px 50px rgba(0,0,0,.5);
}

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

.login-logo i {
    font-size: 3rem;
    background: linear-gradient(135deg, #60a5fa, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 10px;
    display: block;
}

.login-logo h1 {
    color: white;
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 4px;
}

.login-logo p {
    color: rgba(255,255,255,.5);
    font-size: .85rem;
}

.login-form .form-label { color: rgba(255,255,255,.8); }

.login-form .form-control {
    background: rgba(255,255,255,.08);
    border-color: rgba(255,255,255,.15);
    color: white;
}

.login-form .form-control::placeholder { color: rgba(255,255,255,.35); }

.login-form .form-control:focus {
    border-color: #60a5fa;
    background: rgba(255,255,255,.12);
    box-shadow: 0 0 0 3px rgba(96,165,250,.2);
}

.login-btn {
    width: 100%;
    padding: 12px;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: white;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: var(--transition);
    margin-top: 8px;
}

.login-btn:hover {
    box-shadow: 0 6px 20px rgba(37,99,235,.5);
    transform: translateY(-1px);
}

.login-error {
    background: rgba(220,38,38,.2);
    border: 1px solid rgba(220,38,38,.4);
    color: #fca5a5;
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: .875rem;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* ------ PROFILE PAGE ------ */
.profile-avatar-lg {
    width: 80px; height: 80px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2rem;
    font-weight: 800;
    margin: 0 auto 16px;
}

/* ------ AUDIT LOG ------ */
.log-action {
    font-family: 'Courier New', monospace;
    font-size: .8rem;
    background: #f1f5f9;
    padding: 2px 8px;
    border-radius: 4px;
    color: var(--primary);
}

/* ------ PDF PRINT ------ */
@media print {
    .sidebar, .topbar, .btn, .alert { display: none !important; }
    .main-content { margin-left: 0; }
    .page-content { padding: 0; }
    body { background: white; }
}
