/* ===================================
   COMPONENTS - Control 2026
   =================================== */

/* ========== CARDS ========== */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--duration-base) var(--ease-out);
}

.card:hover {
    border-color: var(--border-hover);
}

.card-glow {
    background: var(--gradient-card);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--space-4);
}

.card-title {
    font-family: var(--font-display);
    font-size: var(--text-base);
    font-weight: 600;
}

/* ========== STAT CARDS ========== */
.stat-card {
    display: flex;
    flex-direction: column;
    gap: var(--space-3);
}

.stat-label {
    font-size: var(--text-sm);
    color: var(--text-muted);
    font-weight: 500;
}

.stat-value {
    font-family: var(--font-display);
    font-size: var(--text-3xl);
    font-weight: 700;
    letter-spacing: -0.02em;
}

.stat-trend {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    font-size: var(--text-sm);
    font-weight: 500;
}

.stat-trend.up {
    color: var(--success);
}

.stat-trend.down {
    color: var(--error);
}

/* ========== BUTTONS ========== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    height: 44px;
    padding: 0 var(--space-6);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 600;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.97);
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn svg {
    width: 18px;
    height: 18px;
}

.btn-primary {
    background: transparent;
    color: #10B981;
    font-weight: 600;
    border: 2px solid #10B981;
}

.btn-primary:hover:not(:disabled) {
    background: #10B981;
    color: #000;
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--dark-600);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--dark-500);
    border-color: var(--border-hover);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--dark-600);
    color: var(--text-primary);
    border-color: var(--border-hover);
}

.btn-sm {
    height: 36px;
    padding: 0 var(--space-4);
    font-size: var(--text-xs);
}

.btn-lg {
    height: 52px;
    padding: 0 var(--space-8);
    font-size: var(--text-base);
}

.btn-danger {
    background: transparent;
    color: #ef4444;
    border: 2px solid #ef4444;
}

.btn-danger:hover {
    background: #ef4444;
    color: white;
}

.btn-icon {
    width: 44px;
    height: 44px;
    padding: 0;
    background: var(--dark-600);
    color: var(--text-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--primary-400);
    border-color: var(--border-active);
}

.btn-icon svg {
    width: 20px;
    height: 20px;
}

.btn-icon-sm {
    width: 32px;
    height: 32px;
    padding: 0;
    background: transparent;
    color: var(--text-muted);
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-base) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-sm:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-icon-sm svg {
    width: 16px;
    height: 16px;
}

/* ========== INPUTS ========== */
.form-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-2);
    margin-bottom: var(--space-5);
}

.label {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
}

.label-sm {
    font-size: var(--text-xs);
    color: var(--text-muted);
}

.input,
.select {
    width: 100%;
    height: 48px;
    padding: 0 var(--space-4);
    font-family: var(--font-body);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--dark-700);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    transition: all var(--duration-fast) var(--ease-out);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-4);
    margin-top: var(--space-6);
}

.modal-footer .btn {
    flex: 1;
    min-width: 0;
}

.input::placeholder {
    color: var(--text-muted);
    opacity: 0.8;
}

.input:hover {
    border-color: var(--border-hover);
}

.input:focus {
    outline: none;
    border-color: var(--primary-500);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

.select {
    appearance: none;
    background-image: 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='%2371717A' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
    padding-right: 48px;
}

.grid-2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-4);
}

/* ========== RADIO GROUP ========== */
.radio-group {
    display: flex;
    gap: var(--space-2);
    padding: var(--space-1);
    background: var(--dark-700);
    border-radius: var(--radius-md);
}

.radio-option {
    flex: 1;
    position: relative;
}

.radio-option input {
    position: absolute;
    opacity: 0;
}

.radio-fake {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 40px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-muted);
    transition: all var(--duration-fast) var(--ease-out);
}

.radio-option input:checked+.radio-fake {
    background: var(--dark-500);
    color: var(--text-primary);
}

.radio-option input:checked+.radio-fake.type-expense {
    background: var(--error-bg);
    color: var(--error);
}

.radio-option input:checked+.radio-fake.type-income {
    background: var(--success-bg);
    color: var(--success);
}

/* ========== COLOR OPTIONS ========== */
.color-options,
.color-options-card {
    display: flex;
    gap: var(--space-3);
    flex-wrap: wrap;
}

.color-options input,
.color-options-card input {
    display: none;
}

.color-options span {
    display: block;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
}

.color-options-card span {
    display: block;
    width: 64px;
    height: 44px;
    border-radius: var(--radius-md);
    cursor: pointer;
    border: 2px solid transparent;
    transition: all var(--duration-fast) var(--ease-out);
    flex-shrink: 0;
}

.color-options input:checked+span,
.color-options-card input:checked+span {
    border-color: var(--text-primary);
    transform: scale(1.1);
    box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.1);
}

/* ========== BADGES ========== */
.badge {
    display: inline-flex;
    align-items: center;
    height: 24px;
    padding: 0 var(--space-3);
    font-size: 11px;
    font-weight: 600;
    border-radius: var(--radius-full);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-primary {
    background: rgba(99, 102, 241, 0.15);
    color: var(--primary-400);
}

.badge-success {
    background: var(--success-bg);
    color: var(--success);
}

.badge-error {
    background: var(--error-bg);
    color: var(--error);
}

/* ========== MODAL ========== */
dialog.modal {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: var(--space-6);
    border: none;
    background: transparent;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

dialog.modal[open] {
    display: flex;
}

dialog.modal::backdrop {
    background: var(--bg-overlay);
    backdrop-filter: blur(12px);
}

.modal-content {
    background: var(--dark-800);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    width: 100%;
    max-width: 480px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    animation: modal-in 250ms var(--ease-out);
}

@keyframes modal-in {
    from {
        opacity: 0;
        transform: scale(0.95) translateY(10px);
    }

    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
}

.modal-title {
    font-family: var(--font-display);
    font-size: var(--text-xl);
    font-weight: 600;
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid var(--border);
}

.close-modal {
    width: 36px;
    height: 36px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text-muted);
    cursor: pointer;
    transition: all var(--duration-fast) var(--ease-out);
    display: flex;
    align-items: center;
    justify-content: center;
}

.close-modal:hover {
    background: var(--error-bg);
    color: var(--error);
    border-color: var(--error);
}

/* ========== ALERTS ========== */
.alert {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
}

.alert-error {
    background: var(--error-bg);
    color: var(--error);
}

.alert-success {
    background: var(--success-bg);
    color: var(--success);
}

/* ========== SPINNER ========== */
.spinner,
.carregador {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spin 600ms linear infinite;
}

.carregador-sm {
    width: 16px;
    height: 16px;
}

.carregador-lg {
    width: 40px;
    height: 40px;
    border-width: 3px;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========== EMPTY STATE ========== */
.empty-state {
    text-align: center;
    padding: var(--space-12);
    color: var(--text-muted);
    background: var(--bg-card);
    border: 1px dashed var(--border);
    border-radius: var(--radius-xl);
}

/* ========== PROGRESS ========== */
.progress-bar {
    height: 8px;
    background: var(--dark-600);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: var(--gradient-primary);
    border-radius: var(--radius-full);
    transition: width var(--duration-slow) var(--ease-out);
}

/* ========== JS MODAL CLASSES ========== */
.modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-container {
    background: var(--dark-800);
    border: 1px solid var(--border);
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 480px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transform: scale(0.95) translateY(10px);
    transition: all 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
    position: relative;
    z-index: 10000;
}

.modal-container.active {
    transform: scale(1) translateY(0);
}

.modal-container.modal-lg {
    max-width: 800px;
}