/* ============================================
   ContaSmart - Sistema para Contadores
   Design System & Global Styles
   ============================================ */

:root {
    --primary: #1e3a5f;
    --primary-light: #2c5282;
    --primary-dark: #152a45;
    --accent: #2a9d8f;
    --accent-light: #3dbdad;
    --danger: #e63946;
    --warning: #f4a261;
    --success: #2a9d8f;
    --gray-50: #f8f9fa;
    --gray-100: #f1f3f5;
    --gray-200: #e9ecef;
    --gray-300: #dee2e6;
    --gray-400: #ced4da;
    --gray-500: #adb5bd;
    --gray-600: #6c757d;
    --gray-700: #495057;
    --gray-800: #343a40;
    --gray-900: #212529;
    --white: #ffffff;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.12);
    --radius: 8px;
    --radius-lg: 12px;
    --sidebar-width: 260px;
    --topbar-height: 64px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--gray-100);
    color: var(--gray-800);
    line-height: 1.5;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--primary);
    color: var(--white);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: width 0.3s ease;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 20px;
    font-weight: 700;
}

.logo i { color: var(--accent); font-size: 24px; }

.sidebar-toggle {
    background: none;
    border: none;
    color: var(--gray-400);
    cursor: pointer;
    font-size: 18px;
    display: none;
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius);
    color: rgba(255,255,255,0.7);
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 4px;
    font-size: 14px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.1);
    color: var(--white);
}

.nav-item.active {
    background: rgba(42,157,143,0.2);
    color: var(--accent-light);
    font-weight: 500;
}

.nav-item i { width: 20px; text-align: center; }

.nav-section {
    font-size: 11px;
    text-transform: uppercase;
    color: rgba(255,255,255,0.4);
    padding: 16px 16px 8px;
    letter-spacing: 0.5px;
}

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

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: rgba(255,255,255,0.5); }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* Top Bar */
.top-bar {
    height: var(--topbar-height);
    background: var(--white);
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.top-bar h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--gray-900);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 20px;
}

.search-box {
    display: flex;
    align-items: center;
    background: var(--gray-100);
    border-radius: 20px;
    padding: 8px 16px;
    gap: 8px;
}

.search-box input {
    border: none;
    background: none;
    outline: none;
    font-size: 13px;
    width: 200px;
    font-family: inherit;
}

.notifications {
    position: relative;
    cursor: pointer;
    color: var(--gray-600);
    font-size: 18px;
}

.notifications .badge {
    position: absolute;
    top: -5px;
    right: -8px;
    background: var(--danger);
    color: white;
    font-size: 10px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.top-bar-user {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
    color: var(--gray-700);
}

/* Content Area */
.content-area {
    padding: 32px;
    flex: 1;
}

/* Cards Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 28px;
}

.stat-card {
    background: var(--white);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    transition: transform 0.2s, box-shadow 0.2s;
}

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

.stat-card .stat-icon {
    width: 44px;
    height: 44px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 12px;
}

.stat-card .stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--gray-900);
}

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

.stat-card .stat-change {
    font-size: 12px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
}

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

/* Panels */
.panels-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 28px;
}

.panel {
    background: var(--white);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--gray-200);
    overflow: hidden;
}

.panel-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-header h3 {
    font-size: 15px;
    font-weight: 600;
    color: var(--gray-800);
}

.panel-body { padding: 20px 24px; }

/* Tables */
.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th {
    text-align: left;
    padding: 12px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--gray-600);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: var(--gray-50);
    border-bottom: 1px solid var(--gray-200);
}

.data-table td {
    padding: 14px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
}

.data-table tr:hover td { background: var(--gray-50); }

/* Status Badges */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 500;
}

.status-badge.success { background: #d4edda; color: #155724; }
.status-badge.warning { background: #fff3cd; color: #856404; }
.status-badge.danger { background: #f8d7da; color: #721c24; }
.status-badge.info { background: #d1ecf1; color: #0c5460; }
.status-badge.neutral { background: var(--gray-200); color: var(--gray-700); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    font-family: inherit;
}

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

.btn-secondary {
    background: var(--white);
    color: var(--gray-700);
    border: 1px solid var(--gray-300);
}
.btn-secondary:hover { background: var(--gray-50); }

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

.btn-sm { padding: 6px 12px; font-size: 12px; }
.btn-icon {
    width: 32px; height: 32px; padding: 0;
    display: flex; align-items: center; justify-content: center;
    border-radius: 6px; border: 1px solid var(--gray-300);
    background: white; cursor: pointer; color: var(--gray-600);
}
.btn-icon:hover { background: var(--gray-50); }

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

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

.form-control {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(42,157,143,0.1);
}

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

/* Modal */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

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

.modal {
    background: var(--white);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 600px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--gray-200);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h2 { font-size: 18px; font-weight: 600; }

.modal-close {
    background: none; border: none;
    font-size: 20px; cursor: pointer;
    color: var(--gray-500);
}

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--gray-200);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* Activity Items */
.activity-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
}

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

.activity-icon {
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; flex-shrink: 0;
}

.activity-text { font-size: 13px; color: var(--gray-700); }
.activity-time { font-size: 11px; color: var(--gray-500); margin-top: 2px; }

/* Page Header */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header-actions {
    display: flex;
    gap: 12px;
}

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

.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--gray-300);
    border-radius: var(--radius);
    font-size: 13px;
    font-family: inherit;
    background: white;
}

/* Client Detail */
.client-header {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 24px;
    padding: 24px;
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
}

.client-avatar-lg {
    width: 64px; height: 64px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px; font-weight: 600;
}

.client-info h2 { font-size: 20px; font-weight: 600; }
.client-info p { font-size: 13px; color: var(--gray-600); }

.tabs {
    display: flex;
    border-bottom: 2px solid var(--gray-200);
    margin-bottom: 24px;
}

.tab {
    padding: 12px 20px;
    font-size: 13px;
    font-weight: 500;
    color: var(--gray-600);
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab:hover { color: var(--gray-800); }
.tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

/* Messages */
.message-list { display: flex; flex-direction: column; gap: 12px; }

.message-item {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    border-radius: var(--radius);
    border: 1px solid var(--gray-200);
    cursor: pointer;
    transition: background 0.2s;
}

.message-item:hover { background: var(--gray-50); }
.message-item.unread { border-left: 3px solid var(--accent); }

.message-avatar {
    width: 40px; height: 40px; border-radius: 50%;
    background: var(--primary-light); color: white;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 600; flex-shrink: 0;
}

.message-content { flex: 1; }
.message-sender { font-size: 14px; font-weight: 500; }
.message-preview { font-size: 13px; color: var(--gray-600); margin-top: 2px; }
.message-time { font-size: 11px; color: var(--gray-500); }

/* Financial */
.financial-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.fin-card {
    background: white;
    border-radius: var(--radius-lg);
    padding: 20px;
    border: 1px solid var(--gray-200);
    text-align: center;
}

.fin-card .fin-value {
    font-size: 24px; font-weight: 700; margin: 8px 0;
}
.fin-card .fin-label { font-size: 12px; color: var(--gray-600); }

/* Calendar */
.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-header {
    text-align: center;
    font-size: 11px;
    font-weight: 600;
    color: var(--gray-600);
    padding: 8px;
}

.calendar-day {
    text-align: center;
    padding: 10px 6px;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    position: relative;
}

.calendar-day:hover { background: var(--gray-100); }
.calendar-day.has-event::after {
    content: '';
    position: absolute;
    bottom: 4px;
    left: 50%;
    transform: translateX(-50%);
    width: 5px; height: 5px;
    border-radius: 50%;
    background: var(--danger);
}
.calendar-day.today {
    background: var(--accent);
    color: white;
    font-weight: 600;
}

/* Portal do Cliente */
.portal-banner {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    border-radius: var(--radius-lg);
    padding: 32px;
    color: white;
    margin-bottom: 28px;
}
.portal-banner h2 { font-size: 24px; margin-bottom: 8px; }
.portal-banner p { opacity: 0.8; font-size: 14px; }

/* Upload Area */
.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: var(--radius-lg);
    padding: 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
}
.upload-area:hover {
    border-color: var(--accent);
    background: rgba(42,157,143,0.02);
}
.upload-area i { font-size: 36px; color: var(--gray-400); margin-bottom: 12px; }
.upload-area p { color: var(--gray-600); font-size: 14px; }

/* Toggle Switch for Portal */
.portal-switch {
    display: flex;
    background: var(--gray-200);
    border-radius: 20px;
    padding: 4px;
    margin-bottom: 28px;
    width: fit-content;
}

.portal-switch-btn {
    padding: 8px 20px;
    border-radius: 16px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    border: none;
    background: transparent;
    color: var(--gray-600);
    font-family: inherit;
    transition: all 0.2s;
}

.portal-switch-btn.active {
    background: var(--primary);
    color: white;
}

/* Document list */
.doc-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    border: 1px solid var(--gray-200);
    border-radius: var(--radius);
    margin-bottom: 8px;
    transition: background 0.2s;
}
.doc-item:hover { background: var(--gray-50); }

.doc-item-left {
    display: flex; align-items: center; gap: 12px;
}

.doc-icon {
    width: 36px; height: 36px;
    border-radius: 6px;
    display: flex; align-items: center; justify-content: center;
    font-size: 16px;
}
.doc-icon.pdf { background: #fde8e8; color: #e63946; }
.doc-icon.xml { background: #dbeafe; color: #2563eb; }
.doc-icon.xls { background: #d4edda; color: #155724; }

.doc-name { font-size: 13px; font-weight: 500; }
.doc-meta { font-size: 11px; color: var(--gray-500); }

/* Settings */
.settings-section {
    background: white;
    border-radius: var(--radius-lg);
    border: 1px solid var(--gray-200);
    padding: 24px;
    margin-bottom: 20px;
}

.settings-section h3 {
    font-size: 16px; font-weight: 600;
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--gray-200);
}

/* Responsive */
@media (max-width: 1024px) {
    .panels-grid { grid-template-columns: 1fr; }
    .financial-summary { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 768px) {
    .sidebar { width: 0; overflow: hidden; }
    .sidebar.open { width: var(--sidebar-width); }
    .main-content { margin-left: 0; }
    .sidebar-toggle { display: block; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .form-row { grid-template-columns: 1fr; }
    .top-bar { padding: 0 16px; }
    .content-area { padding: 20px 16px; }
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.content-area > * {
    animation: fadeIn 0.3s ease;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--gray-500);
}
.empty-state i { font-size: 48px; margin-bottom: 16px; }
.empty-state h3 { font-size: 18px; color: var(--gray-700); margin-bottom: 8px; }
