@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&display=swap');

:root {
    --bg-primary: #fafbfc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(255, 255, 255, 0.95);
    --bg-glass: rgba(255, 255, 255, 0.8);
    --border-glass: rgba(0, 0, 0, 0.04);
    --border-glow: rgba(0, 0, 0, 0.08);
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --accent: #7c3aed;
    --accent-glow: rgba(124, 58, 237, 0.15);
    --accent-hover: #6d28d9;
    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.1);
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.1);
    --warning: #f59e0b;
    --gradient-hero: linear-gradient(135deg, #7c3aed, #06b6d4);
    --gradient-card: linear-gradient(145deg, #ffffff, #f8fafc);
    --radius-sm: 10px;
    --radius-lg: 20px;
    --radius-xl: 28px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 10px 25px -5px rgba(0, 0, 0, 0.05), 0 8px 10px -6px rgba(0, 0, 0, 0.03);
    --shadow-lg: 0 25px 50px -12px rgba(0, 0, 0, 0.08);
    --shadow-glow: 0 0 40px var(--accent-glow);
    --transition: 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background: var(--bg-primary);
    color: var(--text-primary);
    font-family: 'Manrope', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    height: 100vh;
    overflow: hidden;
    letter-spacing: -0.02em;
    line-height: 1.6;
}

#app-content {
    display: flex;
}

.auth-wrapper {
    position: fixed;
    inset: 0;
    background: linear-gradient(135deg, #f0f4ff 0%, #e8f0fe 50%, #faf5ff 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-box {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(0, 0, 0, 0.04);
    padding: clamp(2rem, 5vw, 4rem) clamp(1.5rem, 4vw, 3rem);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    width: 90%;
    max-width: 420px;
    text-align: center;
    animation: slideUp 0.5s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.auth-box h2 {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin-bottom: 2rem;
    font-weight: 800;
    font-size: clamp(1.2rem, 3vw, 1.5rem);
    letter-spacing: -0.03em;
}

.auth-input {
    width: 100%;
    background: rgba(0, 0, 0, 0.02);
    color: var(--text-primary);
    border: 2px solid var(--border-glass);
    border-radius: var(--radius-lg);
    padding: 1rem 1.5rem;
    font-size: clamp(1.4rem, 3vw, 1.8rem);
    text-align: center;
    letter-spacing: 0.8rem;
    margin-bottom: 2rem;
    outline: none;
    font-family: 'Manrope', monospace;
    font-weight: 700;
    transition: var(--transition);
}

.auth-input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: white;
}

/* ============ LAYOUT PRINCIPAL ============ */
.crm-layout {
    display: flex;
    width: 100vw;
    height: 100vh;
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 280px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    padding: 2rem 1.5rem;
    border-right: 1px solid var(--border-glass);
    box-shadow: var(--shadow-sm);
    z-index: 10;
}

.sidebar-logo {
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: clamp(1.1rem, 2vw, 1.4rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    padding: 0 1rem 3rem 1rem;
}

.nav-link {
    color: var(--text-secondary);
    text-decoration: none;
    padding: 0.85rem 1.2rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 600;
    transition: var(--transition);
    margin-bottom: 0.3rem;
    display: block;
    position: relative;
}

.nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%) scale(0);
    width: 4px;
    height: 60%;
    background: var(--accent);
    border-radius: 0 10px 10px 0;
    transition: var(--transition);
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-primary);
    color: var(--accent);
    box-shadow: var(--shadow-sm);
}

.nav-link:hover::before,
.nav-link.active::before {
    transform: translateY(-50%) scale(1);
}

/* ============ MAIN AREA ============ */
.main-area {
    flex: 1;
    padding: clamp(1rem, 3vw, 2.5rem) clamp(1rem, 4vw, 3.5rem);
    overflow-y: auto;
    background: var(--bg-primary);
}

/* Scrollbar */
.main-area::-webkit-scrollbar {
    width: 8px;
}

.main-area::-webkit-scrollbar-track {
    background: transparent;
}

.main-area::-webkit-scrollbar-thumb {
    background: var(--text-muted);
    border-radius: 10px;
    border: 2px solid transparent;
    background-clip: padding-box;
}

/* ============ PAGE HEADER ============ */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    flex-wrap: wrap;
    gap: 1rem;
}

.page-title {
    font-size: clamp(1.5rem, 4vw, 2.2rem);
    font-weight: 800;
    letter-spacing: -0.04em;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============ PANELS ============ */
.panel {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-xl);
    padding: clamp(1.2rem, 3vw, 2rem);
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.panel:hover {
    box-shadow: var(--shadow-md);
    border-color: var(--border-glow);
}

/* ============ METRIC GRID ============ */
.metric-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.metric-card {
    background: var(--bg-secondary);
    border: 1px solid var(--border-glass);
    padding: clamp(1.2rem, 2vw, 1.8rem);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.metric-card::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 3px;
    background: var(--gradient-hero);
    opacity: 0;
    transition: var(--transition);
}

.metric-card:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-md);
    border-color: var(--border-glow);
}

.metric-card:hover::after {
    opacity: 1;
}

.metric-label {
    font-size: 0.75rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.12em;
    margin-bottom: 0.5rem;
}

.metric-value {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 800;
    letter-spacing: -0.03em;
    color: var(--text-primary);
}

/* ============ FORMS ============ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 1.5rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.input-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.1em;
}

.input-field {
    padding: 0.9rem 1.2rem;
    background: var(--bg-primary);
    border: 2px solid var(--border-glass);
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: var(--transition);
    outline: none;
    font-family: 'Manrope', sans-serif;
    font-weight: 500;
    width: 100%;
}

.input-field:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-glow);
    background: white;
}

select.input-field {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.2rem center;
    padding-right: 3rem;
    cursor: pointer;
}

/* ============ BOTÕES ============ */
.btn {
    padding: 0.8rem 1.8rem;
    border-radius: var(--radius-lg);
    font-size: 0.9rem;
    font-weight: 700;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    font-family: 'Manrope', sans-serif;
    letter-spacing: -0.02em;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--accent);
    color: white;
    box-shadow: 0 4px 15px var(--accent-glow);
}

.btn-primary:hover {
    background: var(--accent-hover);
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--accent-glow);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 2px solid var(--border-glass);
}

.btn-ghost:hover {
    background: var(--bg-primary);
    color: var(--text-primary);
    border-color: var(--border-glow);
    transform: translateY(-2px);
}

.btn-ghost:active {
    transform: translateY(0);
}

/* ============ DATA ROW ============ */
.data-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.2rem 0;
    border-bottom: 1px solid var(--border-glass);
    transition: var(--transition);
    gap: 1rem;
    flex-wrap: wrap;
}

.data-row:hover {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    padding-left: 1rem;
    padding-right: 1rem;
    margin-left: -1rem;
    margin-right: -1rem;
}

.data-row:last-child {
    border-bottom: none;
}

.data-title {
    font-weight: 700;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.data-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.2rem;
    font-weight: 500;
}

/* ============ BALANCE SECTION ============ */
.balance-section {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 2px solid var(--border-glass);
    flex-wrap: wrap;
    gap: 1rem;
}

.amount-group {
    display: flex;
    gap: 1.5rem;
    flex-wrap: wrap;
}

#total-balance {
    font-size: clamp(2rem, 5vw, 2.8rem);
    font-weight: 800;
    background: var(--gradient-hero);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

#total-income {
    color: var(--success);
    font-weight: 800;
    font-size: 1.1rem;
}

#total-expense {
    color: var(--danger);
    font-weight: 800;
    font-size: 1.1rem;
}

#total-loan {
    color: var(--text-secondary);
    font-weight: 700;
    font-size: 1rem;
}

/* ============ RESPONSIVIDADE ============ */

/* Tablet */
@media (max-width: 1024px) {
    .sidebar {
        width: 240px;
        padding: 1.5rem 1rem;
    }

    .metric-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 1rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .balance-section {
        flex-direction: column;
        align-items: flex-start;
    }

    .amount-group {
        width: 100%;
        justify-content: space-between;
    }
}

/* Mobile Grande */
@media (max-width: 768px) {
    body {
        overflow: auto;
        height: auto;
    }

    .crm-layout {
        flex-direction: column;
        height: auto;
        min-height: 100vh;
    }

    .sidebar {
        width: 100%;
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
        padding: 1rem 1.5rem;
        border-right: none;
        border-bottom: 1px solid var(--border-glass);
        flex-wrap: wrap;
        gap: 1rem;
    }

    .sidebar-logo {
        padding: 0;
        font-size: 1.2rem;
    }

    .sidebar nav {
        display: flex;
        gap: 0.5rem;
        order: 3;
        width: 100%;
        overflow-x: auto;
        padding-bottom: 0.5rem;
    }

    .nav-link {
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }

    .main-area {
        padding: 1.5rem;
    }

    .metric-grid {
        grid-template-columns: 1fr;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .data-row {
        flex-direction: column;
        align-items: flex-start;
    }
}

/* Mobile Pequeno */
@media (max-width: 480px) {
    .auth-box {
        padding: 2rem 1.5rem;
    }

    .sidebar {
        padding: 1rem;
    }

    .main-area {
        padding: 1rem;
    }

    .page-title {
        font-size: 1.3rem;
    }

    .btn {
        padding: 0.7rem 1.2rem;
        font-size: 0.8rem;
        width: 100%;
        justify-content: center;
    }

    .metric-card {
        padding: 1rem;
    }

    .metric-value {
        font-size: 1.3rem;
    }

    .input-field {
        padding: 0.7rem 1rem;
        font-size: 0.85rem;
    }
}

/* ============ UTILITIES ============ */
/* Focus visible para acessibilidade */
*:focus-visible {
    outline: 2px solid var(--accent);
    outline-offset: 3px;
    border-radius: 4px;
}

/* Animações de entrada */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.metric-card,
.panel {
    animation: fadeIn 0.5s ease backwards;
}

.metric-card:nth-child(1) {
    animation-delay: 0.1s;
}

.metric-card:nth-child(2) {
    animation-delay: 0.2s;
}

.metric-card:nth-child(3) {
    animation-delay: 0.3s;
}

.metric-card:nth-child(4) {
    animation-delay: 0.4s;
}

/* Animação do gráfico */
canvas#monthly-chart {
    animation: fadeInUp 0.8s ease backwards;
    max-height: 400px;
    width: 100% !important;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Animação do saldo */
#total-balance {
    transition: all 0.3s ease;
}

#total-balance:hover {
    transform: scale(1.05);
}

/* Métricas com hover */
#total-income, #total-expense, #total-loan {
    transition: all 0.3s ease;
    cursor: default;
}

#total-income:hover {
    transform: translateY(-2px);
    text-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

#total-expense:hover {
    transform: translateY(-2px);
    text-shadow: 0 4px 12px rgba(239, 68, 68, 0.3);
}

#total-loan:hover {
    transform: translateY(-2px);
    text-shadow: 0 4px 12px rgba(100, 116, 139, 0.3);
}