/**
 * CRM System - Clean Tailwind-inspired Theme
 * Design: Clean Dark Mode
 */

/* ==================== TAILWIND COLORS & VARS ==================== */
:root {
    /* Slate Scheme (Tailwind style) */
    --c-bg: #0f172a;        /* slate-900 */
    --c-surface: #1e293b;   /* slate-800 */
    --c-surface-hover: #334155; /* slate-700 */
    
    --c-border: #334155;    /* slate-700 */
    --c-border-subtle: rgba(255, 255, 255, 0.08);

    --c-text-primary: #f1f5f9;   /* slate-100 */
    --c-text-secondary: #94a3b8; /* slate-400 */
    --c-text-muted: #64748b;     /* slate-500 */

    /* Brand Colors - Standard Blue */
    --c-primary: #3b82f6;        /* blue-500 */
    --c-primary-hover: #2563eb;  /* blue-600 */
    --c-primary-fg: #ffffff;

    /* Status Colors */
    --c-success: #10b981; /* emerald-500 */
    --c-warning: #f59e0b; /* amber-500 */
    --c-error: #ef4444;   /* red-500 */
    --c-info: #06b6d4;    /* cyan-500 */

    /* Spacing & Layout */
    --radius-sm: 0.25rem;
    --radius-md: 0.375rem; /* Tailwind default rounded-md */
    --radius-lg: 0.5rem;   /* Tailwind rounded-lg */
    --radius-xl: 0.75rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* Transitions */
    --transition: 150ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ==================== RESET & BASE ==================== */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: 'Inter', ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background-color: var(--c-bg);
    color: var(--c-text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    font-size: 0.95rem;
}

h1, h2, h3, h4, h5, h6 { color: #fff; font-weight: 600; letter-spacing: -0.025em; margin-bottom: 1rem; }
h1 { font-size: 1.875rem; line-height: 2.25rem; }
h2 { font-size: 1.5rem; line-height: 2rem; }
h3 { font-size: 1.25rem; line-height: 1.75rem; }

a { color: var(--c-primary); text-decoration: none; transition: var(--transition); }
a:hover { color: var(--c-primary-hover); }

/* ==================== LAYOUT ==================== */
.container {
    max-width: 1280px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

/* ==================== NAVIGATION ==================== */
.navbar {
    background-color: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--c-border);
    position: sticky;
    top: 0;
    z-index: 50;
    padding: 0.75rem 0;
}

.navbar-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.navbar-menu {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}

.navbar-link {
    display: block;
    padding: 0.5rem 0.75rem;
    color: var(--c-text-secondary);
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.navbar-link:hover {
    color: var(--c-text-primary);
    background-color: var(--c-surface-hover);
}

.navbar-link.active {
    color: var(--c-primary);
    background-color: rgba(59, 130, 246, 0.1);
}

/* ==================== COMPONENTS: CARD ==================== */
.card {
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    padding: 1.5rem;
    margin-bottom: 1.5rem;
}

.card:hover { border-color: #475569; }

/* ==================== COMPONENTS: BUTTONS ==================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    gap: 0.5rem;
}

.btn-sm { padding: 0.25rem 0.75rem; font-size: 0.75rem; }

.btn-primary {
    background-color: var(--c-primary);
    color: var(--c-primary-fg);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
}
.btn-primary:hover { background-color: var(--c-primary-hover); }

.btn-secondary {
    background-color: var(--c-surface);
    border-color: var(--c-border);
    color: var(--c-text-primary);
}
.btn-secondary:hover { background-color: var(--c-surface-hover); border-color: #475569; }

.btn-danger {
    background-color: var(--c-error);
    color: white;
}
.btn-danger:hover { filter: brightness(90%); }

.btn-success { background-color: var(--c-success); color: white; }
.btn-info { background-color: var(--c-info); color: white; }

.action-buttons {
    display: flex;
    gap: 0.5rem;
}

/* ==================== COMPONENTS: FORMS ==================== */
.form-group { margin-bottom: 1.25rem; }

.form-label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--c-text-secondary);
    margin-bottom: 0.5rem;
}

.form-control {
    display: block;
    width: 100%;
    padding: 0.625rem 0.875rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: var(--c-text-primary);
    background-color: #0f172a; /* Darker than card */
    border: 1px solid var(--c-border);
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.form-control:focus {
    outline: none;
    border-color: var(--c-primary);
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.2);
}

/* ==================== COMPONENTS: TABLE ==================== */
.table-container {
    overflow-x: auto;
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
}

table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.875rem;
}

thead {
    background-color: #0f172a;
    border-bottom: 1px solid var(--c-border);
}

th {
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    color: var(--c-text-secondary);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--c-border-subtle);
    color: var(--c-text-primary);
}

tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background-color: rgba(255,255,255,0.02); }

/* ==================== COMPONENTS: MODAL ==================== */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9999; /* Garante que fique acima de tudo */
    background-color: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.modal.active {
    display: flex;
    opacity: 1;
}

.modal-content {
    background-color: var(--c-surface);
    width: 100%;
    max-width: 32rem;
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
    border: 1px solid var(--c-border);
    padding: 1.5rem;
    transform: scale(0.95);
    transition: transform 0.2s ease;
    max-height: 90vh;
    overflow-y: auto;
}

.modal.active .modal-content {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--c-border-subtle);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--c-text-muted);
    font-size: 1.5rem;
    cursor: pointer;
}
.modal-close:hover { color: var(--c-text-primary); }

/* ==================== UTILS & BADGES ==================== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1;
}

.badge-success { background-color: rgba(16, 185, 129, 0.1); color: #34d399; border: 1px solid rgba(16, 185, 129, 0.2); }
.badge-warning { background-color: rgba(245, 158, 11, 0.1); color: #fbbf24; border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-error { background-color: rgba(239, 68, 68, 0.1); color: #f87171; border: 1px solid rgba(239, 68, 68, 0.2); }
.badge-info { background-color: rgba(59, 130, 246, 0.1); color: #60a5fa; border: 1px solid rgba(59, 130, 246, 0.2); }

/* Loading Animation */
.loading {
    border: 2px solid transparent;
    border-radius: 50%;
    border-top-color: var(--c-primary);
    width: 24px; 
    height: 24px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}
@keyframes spin { 100% { transform: rotate(360deg); } }
/* ==================== DASHBOARD & STATS ==================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-lg);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
    transition: var(--transition);
}

.stat-card:hover { border-color: var(--c-primary); }

.stat-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1rem;
}

.stat-icon {
    width: 3rem;
    height: 3rem;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background-color: rgba(255, 255, 255, 0.05);
    color: var(--c-text-primary);
}

/* Color variations for icons */
.stat-icon.blue { background-color: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.stat-icon.green { background-color: rgba(16, 185, 129, 0.1); color: #34d399; }
.stat-icon.orange { background-color: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.stat-icon.purple { background-color: rgba(139, 92, 246, 0.1); color: #a78bfa; }

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
    color: var(--c-text-primary);
    margin-bottom: 0.25rem;
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--c-text-secondary);
}


/* ==================== TOAST NOTIFICATIONS (NEW) ==================== */
#toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background-color: var(--c-surface);
    color: var(--c-text-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    border: 1px solid var(--c-border);
    padding: 16px;
    min-width: 320px;
    max-width: 400px;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    position: relative;
    overflow: hidden;
    animation: slideInRight 0.3s ease-out forwards;
    transition: all 0.3s ease;
}

.toast.hiding {
    animation: fadeOutDown 0.3s ease-in forwards;
}

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

@keyframes fadeOutDown {
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

.toast-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2rem;
    height: 2rem;
    background-color: rgba(255, 255, 255, 0.05); /* Default */
    border-radius: var(--radius-md);
}

/* Toast Variants */
.toast-success .toast-icon { background-color: rgba(16, 185, 129, 0.1); color: #34d399; }
.toast-success { border-left: 4px solid var(--c-success); }

.toast-error .toast-icon { background-color: rgba(239, 68, 68, 0.1); color: #f87171; }
.toast-error { border-left: 4px solid var(--c-error); }

.toast-warning .toast-icon { background-color: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.toast-warning { border-left: 4px solid var(--c-warning); }

.toast-info .toast-icon { background-color: rgba(59, 130, 246, 0.1); color: #60a5fa; }
.toast-info { border-left: 4px solid var(--c-info); }

.toast-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 2rem;
}

.toast-message {
    font-size: 0.95rem;
    font-weight: 500;
    line-height: 1.4;
}

.toast-close {
    background: transparent;
    border: none;
    color: var(--c-text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
    padding: 0;
    margin-left: 4px;
    align-self: flex-start;
    transition: color 0.2s;
}

.toast-close:hover {
    color: var(--c-text-primary);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background-color: rgba(255, 255, 255, 0.1);
}

.toast-progress-bar {
    height: 100%;
    width: 100%; /* JS vai reduzir para 0 */
    background-color: currentColor; /* Herda a cor do texto do toast (não é ideal, melhor fixar) */
}

/* Fix progress bar colors */
.toast-success .toast-progress-bar { background-color: var(--c-success); }
.toast-error .toast-progress-bar { background-color: var(--c-error); }
.toast-warning .toast-progress-bar { background-color: var(--c-warning); }
.toast-info .toast-progress-bar { background-color: var(--c-info); }



/* ==================== SIDE DRAWER (MODAL MODERNO) ==================== */
/* Transforma o modal central em um painel lateral deslizante */
.modal-drawer {
    justify-content: flex-end; /* Alinha à direita */
    background-color: rgba(0, 0, 0, 0.5); /* Fundo mais suave */
}

.modal-drawer .modal-content {
    height: 100vh;
    max-height: 100vh;
    width: 600px; /* Largura fixa agradável */
    max-width: 100%; /* Responsvel em mobile */
    margin: 0;
    border-radius: 0;
    border-left: 1px solid var(--c-border);
    transform: translateX(100%); /* Começa escondido na direita */
    opacity: 1;
    display: flex;
    flex-direction: column;
}

/* Animação de entrada */
.modal-drawer.active .modal-content {
    animation: drawerSlideIn 0.4s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

/* Animação chave */
@keyframes drawerSlideIn {
    from { transform: translateX(100%); }
    to { transform: translateX(0); }
}

/* Ajustes internos do drawer */
.modal-drawer .modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--c-border);
    background-color: var(--c-surface);
    position: sticky;
    top: 0;
    z-index: 10;
}

.modal-drawer .modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    flex: 1; /* Ocupa o resto do espaço */
}

.modal-drawer form {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Botões fixos no rodapé (opcional, mas bom pra UX) */
.modal-footer-actions {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--c-border);
    background-color: var(--c-surface);
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    position: sticky;
    bottom: 0;
    z-index: 10;
}

/* Responsivo Mobile */
@media (max-width: 768px) {
    .modal-drawer .modal-content {
        width: 100%;
    }
}


/* ==================== AUTH PAGES ==================== */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background-color: var(--c-bg);
    background-image: 
        radial-gradient(at 0% 0%, rgba(59, 130, 246, 0.15) 0px, transparent 50%),
        radial-gradient(at 100% 100%, rgba(16, 185, 129, 0.15) 0px, transparent 50%);
}

.auth-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.glass-card {
    background-color: var(--c-surface);
    border: 1px solid var(--c-border);
    border-radius: var(--radius-xl);
    padding: 2.5rem;
    box-shadow: 0 25px 50px -12px rgb(0 0 0 / 0.25);
    text-align: center;
}

.auth-logo {
    margin-bottom: 2rem;
}
.auth-logo p {
    color: var(--c-text-secondary);
    font-size: 0.95rem;
    margin-top: 0.5rem;
}

.w-full { width: 100%; }

.alert {
    padding: 0.75rem 1rem;
    border-radius: var(--radius-md);
    margin-bottom: 1.5rem;
    font-size: 0.875rem;
    text-align: left;
}
.alert-error {
    background-color: rgba(239, 68, 68, 0.1);
    color: #fca5a5;
    border: 1px solid rgba(239, 68, 68, 0.2);
}
.alert-success {
    background-color: rgba(16, 185, 129, 0.1);
    color: #6ee7b7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.auth-footer {
    margin-top: 2rem;
    color: var(--c-text-muted);
    font-size: 0.875rem;
}

