/**
 * Main App Styles
 * Financial Management Application
 * Professional Blue Theme
 */

:root {
    /* Modern Teal Theme - Balance between modern and trustworthy */
    --primary-teal: #14b8a6;
    --primary-teal-dark: #0f766e;
    --primary-teal-light: #ccfbf1;
}

body {
    background-color: #f8f9fa;
    min-height: 100vh;
    min-height: 100vh;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 0;
    margin: 0;
}

/* App Container */
.app-container {
    max-width: 500px;
    width: 100%;
    background: white;
    border-radius: 0;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.05);
    overflow: visible;
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--primary-teal-dark) 100%);
    color: white;
    padding: 1.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow 0.3s ease;
}

.header.scrolled {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.header h1 {
    font-size: clamp(1.1rem, 3vw, 1.25rem);
    margin: 0 0 0.25rem 0;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header h1 i {
    font-size: 1.3rem;
}

.balance-btn {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    white-space: nowrap;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.balance-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

.balance-btn i {
    font-size: 1rem;
}

/* Hide button text on very small screens, show only icon */
@media (max-width: 380px) {
    .balance-btn .btn-text {
        display: none;
    }

    .balance-btn {
        padding: 0.5rem;
        min-width: 40px;
        justify-content: center;
    }

    .header h1 {
        font-size: 1rem;
    }

    .header h1 i {
        font-size: 1.1rem;
    }

    #user-display {
        font-size: 0.75rem !important;
    }
}

/* Navigation Tabs */
.nav-tabs {
    border-bottom: 2px solid #e9ecef;
    overflow-x: auto;
    overflow-y: hidden;
    flex-wrap: nowrap;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    position: relative;
}

.nav-tabs::-webkit-scrollbar {
    display: none; /* Chrome, Safari, Opera */
}

/* Scroll indicators for tabs */
.tabs-wrapper {
    position: sticky;
    top: 88px; /* Altura del header en desktop */
    z-index: 90;
    background: white;
    transition: box-shadow 0.3s ease;
}

.tabs-wrapper.scrolled {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Ajustar top según tamaño de header en mobile */
@media (max-width: 576px) {
    .tabs-wrapper {
        top: 74px; /* Altura del header en mobile */
    }
}

@media (max-width: 350px) {
    .tabs-wrapper {
        top: 110px; /* Header más alto cuando se apila verticalmente */
    }
}

.scroll-indicator {
    position: absolute;
    top: 0;
    bottom: 2px;
    width: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 10;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.scroll-indicator.visible {
    opacity: 1;
}

.scroll-indicator-left {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.scroll-indicator-right {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.scroll-indicator i {
    color: var(--primary-teal);
    font-size: 1.2rem;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 1));
}

@keyframes pulse {
    0%,
    100% {
        opacity: 0.5;
        transform: scale(1);
    }
    50% {
        opacity: 1;
        transform: scale(1.1);
    }
}

.nav-tabs .nav-link {
    color: #6c757d;
    border: none;
    padding: 0.875rem 1rem;
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.3s ease;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.nav-tabs .nav-link i {
    font-size: 1rem;
}

.nav-tabs .nav-link:hover {
    color: var(--primary-teal);
    border: none;
    background: rgba(20, 184, 166, 0.05);
}

.nav-tabs .nav-link.active {
    color: var(--primary-teal);
    background: transparent;
    border: none;
    border-bottom: 3px solid var(--primary-teal);
}

/* Mobile-specific tab improvements */
@media (max-width: 576px) {
    .nav-tabs {
        border-bottom: 1px solid #e9ecef;
        padding-bottom: 0;
    }

    .scroll-indicator {
        width: 35px;
    }

    .scroll-indicator i {
        font-size: 1.1rem;
    }

    .nav-tabs .nav-link {
        padding: 0.75rem 1rem;
        font-size: 0.85rem;
        min-width: auto;
    }

    .nav-tabs .nav-link i {
        font-size: 1.1rem;
    }

    .nav-tabs .nav-link.active {
        border-bottom-width: 3px;
        font-weight: 600;
    }

    /* Show icon + abbreviated text on mobile */
    .nav-tabs .nav-link .tab-text-full {
        display: none;
    }

    .nav-tabs .nav-link .tab-text-short {
        display: inline;
    }
}

@media (min-width: 577px) {
    .nav-tabs .nav-link .tab-text-full {
        display: inline;
    }

    .nav-tabs .nav-link .tab-text-short {
        display: none;
    }
}

/* Forms */
.form-container {
    padding: 1.5rem;
    padding-bottom: 3rem;
}

/* Tab content should take remaining space */
.tab-content {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.tab-pane {
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.tab-pane.active {
    display: flex;
}

.form-label {
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--primary-teal);
    box-shadow: 0 0 0 0.2rem rgba(0, 102, 204, 0.15);
}

/* Buttons */
.btn-primary {
    background: var(--primary-teal);
    border: none;
    padding: 0.75rem 1.5rem;
    font-weight: 500;
    border-radius: 8px;
    transition: all 0.3s ease;
}

.btn-primary:hover {
    background: var(--primary-teal-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 102, 204, 0.2);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Payment Type Toggle */
.payment-type-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.payment-type-btn {
    flex: 1;
    padding: 0.625rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.payment-type-btn:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
}

.payment-type-btn.active {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: white;
}

/* Transfer Mode Toggle */
.transfer-mode-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.transfer-mode-btn {
    flex: 1;
    padding: 0.625rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.transfer-mode-btn:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
}

.transfer-mode-btn.active {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: white;
}

/* Apartado Action Toggle */
.apartado-action-group {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.apartado-action-btn {
    flex: 1;
    padding: 0.625rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.9rem;
}

.apartado-action-btn:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
}

.apartado-action-btn.active {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: white;
}

/* Conditional Fields */
.hidden {
    display: none !important;
}

/* Account Balance Display */
.account-balance-display {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    padding: 0.75rem 1rem;
    margin-top: 0.5rem;
    margin-bottom: 1rem;
    border: 1px solid #dee2e6;
    display: flex;
    justify-content: space-between;
    align-items: center;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    max-height: 0;
    overflow: hidden;
    padding-top: 0;
    padding-bottom: 0;
}

.account-balance-display:not(.hidden) {
    opacity: 1;
    transform: translateY(0);
    max-height: 100px;
    padding-top: 0.75rem;
    padding-bottom: 0.75rem;
}

.account-balance-display.insufficient {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    border-color: #fca5a5;
}

.account-balance-label {
    font-size: 0.875rem;
    color: #6c757d;
    font-weight: 500;
}

.account-balance-amount {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--primary-teal);
}

.account-balance-amount.negative {
    color: #dc2626;
}

.account-balance-amount.low {
    color: #f59e0b;
}

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

/* Modal */
.modal-header {
    background: linear-gradient(135deg, var(--primary-teal) 0%, var(--primary-teal-dark) 100%);
    color: white;
    border-bottom: none;
}

.modal-header .btn-close {
    filter: brightness(0) invert(1);
}

.balance-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid #e9ecef;
}

.balance-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.balance-section h5 {
    color: var(--primary-teal);
    font-weight: 600;
    margin-bottom: 1rem;
    font-size: 1rem;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.balance-label {
    font-weight: 500;
    color: #495057;
    font-size: 0.95rem;
}

.balance-amount {
    font-weight: 600;
    color: #212529;
    font-size: 1rem;
}

.balance-amount.total {
    color: var(--primary-teal);
    font-size: 1.1rem;
}

.apartado-contrib {
    font-size: 0.85rem;
    color: #6c757d;
    margin-left: 1rem;
}

/* Notifications */
@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}

@keyframes slideUp {
    from {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }

    to {
        opacity: 0;
        transform: translateX(-50%) translateY(-20px);
    }
}

.app-notification {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

/* Responsive */
@media (max-width: 576px) {
    body {
        padding: 0;
        min-height: 100vh;
    }

    .app-container {
        border-radius: 0;
        box-shadow: none;
        max-width: 100%;
        min-height: 100vh;
    }

    .header {
        padding: 1rem 1.25rem;
    }

    .form-container {
        padding: 1.25rem;
    }

    .balance-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.85rem;
    }

    .app-notification {
        min-width: 90% !important;
        font-size: 0.9rem;
    }

    /* Improved mobile padding for forms */
    .form-label {
        font-size: 0.875rem;
        margin-bottom: 0.4rem;
    }

    .form-control,
    .form-select {
        font-size: 0.9rem;
    }

    .btn-primary {
        padding: 0.875rem 1.25rem;
        font-size: 0.95rem;
    }

    /* Better spacing for toggle buttons */
    .payment-type-group,
    .transfer-mode-group,
    .apartado-action-group {
        gap: 0.4rem;
    }

    .payment-type-btn,
    .transfer-mode-btn,
    .apartado-action-btn {
        font-size: 0.85rem;
        padding: 0.55rem 0.5rem;
    }

    /* History mobile improvements */
    .history-container {
        padding: 1rem;
    }

    .transaction-card {
        padding: 0.875rem;
    }

    .transaction-amount {
        font-size: 1rem;
    }

    .transaction-type {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .transaction-detail {
        font-size: 0.825rem;
    }
}

/* Desktop centering with max-width */
@media (min-width: 577px) {
    body {
        padding: 2rem 1rem;
    }

    .app-container {
        border-radius: 12px;
        box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    }
}

/* Very small screens */
@media (max-width: 350px) {
    .header {
        flex-direction: column;
        align-items: flex-start;
        padding: 1rem;
    }

    .header > div:last-child {
        width: 100%;
        display: flex;
        gap: 0.5rem;
    }

    .balance-btn {
        flex: 1;
    }
}

/* ===============================
   HISTORIAL STYLES
=============================== */

.history-container {
    padding: 1.5rem;
    padding-bottom: 3rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* History Filters */
.history-filters-wrapper {
    position: relative;
}

.history-filters {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
    flex-wrap: wrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 0.25rem;
    scrollbar-width: none;
}

.history-filters::-webkit-scrollbar {
    display: none;
}

/* Scroll indicators for filters */
.filters-scroll-indicator {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 35px;
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.filters-scroll-indicator.visible {
    opacity: 1;
}

.filters-scroll-indicator-left {
    left: 0;
    background: linear-gradient(to right, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.filters-scroll-indicator-right {
    right: 0;
    background: linear-gradient(to left, rgba(255, 255, 255, 0.95), rgba(255, 255, 255, 0));
}

.filters-scroll-indicator i {
    color: var(--primary-teal);
    font-size: 1rem;
    animation: pulse 2s ease-in-out infinite;
    filter: drop-shadow(0 0 4px rgba(255, 255, 255, 1));
}

.filter-btn {
    padding: 0.5rem 1rem;
    border: 2px solid #e9ecef;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-weight: 500;
    font-size: 0.85rem;
    color: #6c757d;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.4rem;
    flex-shrink: 0;
}

.filter-btn i {
    font-size: 0.95rem;
}

.filter-btn:hover {
    border-color: var(--primary-teal);
    color: var(--primary-teal);
    transform: translateY(-1px);
}

.filter-btn.active {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: white;
}

/* Mobile optimizations for filters */
@media (max-width: 576px) {
    .history-filters {
        gap: 0.5rem;
        flex-wrap: nowrap;
        margin-bottom: 1rem;
    }

    .filters-scroll-indicator {
        width: 30px;
    }

    .filters-scroll-indicator i {
        font-size: 0.9rem;
    }

    .filter-btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.85rem;
        flex-shrink: 0;
    }

    .filter-btn i {
        font-size: 0.9rem;
    }

    /* Show only icon on very small screens */
    @media (max-width: 380px) {
        .filter-btn .filter-text {
            display: none;
        }

        .filter-btn {
            padding: 0.5rem;
            min-width: 36px;
            justify-content: center;
        }
    }
}

.history-empty {
    text-align: center;
    padding: 3rem 1.5rem;
    color: #6c757d;
}

.history-empty i {
    font-size: 3rem;
    color: #dee2e6;
    margin-bottom: 1rem;
}

.history-empty p {
    margin: 0;
    font-size: 0.95rem;
}

/* Transaction List */
.transaction-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.transaction-card {
    background: #f8f9fa;
    border-radius: 10px;
    padding: 1rem;
    border: 1px solid #e9ecef;
    transition: all 0.3s ease;
}

.transaction-card:hover {
    border-color: var(--primary-teal);
    box-shadow: 0 2px 8px rgba(20, 184, 166, 0.1);
}

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

.transaction-type {
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.transaction-type.ingreso {
    background: #d1fae5;
    color: #047857;
}

.transaction-type.egreso {
    background: #fee2e2;
    color: #991b1b;
}

.transaction-type.transferencia {
    background: #dbeafe;
    color: #1e40af;
}

.transaction-type.apartado {
    background: #fef3c7;
    color: #92400e;
}

.transaction-amount {
    font-size: 1.1rem;
    font-weight: 700;
}

.transaction-amount.positive {
    color: #047857;
}

.transaction-amount.negative {
    color: #991b1b;
}

.transaction-body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.transaction-detail {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    color: #495057;
}

.transaction-detail i {
    color: var(--primary-teal);
    font-size: 0.9rem;
}

.transaction-detail strong {
    color: #212529;
    margin-right: 0.25rem;
}

.transaction-concept {
    font-style: italic;
    color: #6c757d;
    font-size: 0.85rem;
    margin-top: 0.25rem;
}

.transaction-date {
    font-size: 0.75rem;
    color: #6c757d;
    margin-top: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.transaction-date i {
    font-size: 0.7rem;
}

/* Pagination */
.history-pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 1px solid #e9ecef;
}

.pagination-btn {
    padding: 0.5rem 1rem;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.875rem;
}

.pagination-btn:hover:not(:disabled) {
    background: var(--primary-teal);
    border-color: var(--primary-teal);
    color: white;
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-info {
    font-size: 0.875rem;
    color: #6c757d;
    padding: 0 0.5rem;
}

@media (max-width: 576px) {
    .history-container {
        padding: 1rem;
    }

    .history-filters {
        gap: 0.5rem;
        flex-wrap: nowrap;
        margin-bottom: 1rem;
    }

    .filter-btn {
        font-size: 0.8rem;
        padding: 0.45rem 0.85rem;
        flex-shrink: 0;
    }

    .filter-btn i {
        font-size: 0.9rem;
    }

    /* Show only icon on very small screens */
    @media (max-width: 380px) {
        .filter-btn .filter-text {
            display: none;
        }

        .filter-btn {
            padding: 0.5rem;
            min-width: 36px;
            justify-content: center;
        }
    }

    .transaction-card {
        padding: 0.875rem;
    }

    .transaction-header {
        flex-direction: row;
        align-items: start;
        gap: 0.5rem;
    }

    .transaction-type {
        font-size: 0.7rem;
        padding: 0.2rem 0.6rem;
    }

    .transaction-amount {
        font-size: 1rem;
        white-space: nowrap;
    }

    .transaction-detail {
        font-size: 0.825rem;
        gap: 0.4rem;
    }

    .transaction-detail i {
        font-size: 0.85rem;
    }

    .transaction-concept {
        font-size: 0.8rem;
        margin-top: 0.4rem;
    }

    .transaction-date {
        font-size: 0.7rem;
        margin-top: 0.4rem;
    }

    .history-pagination {
        flex-wrap: wrap;
        gap: 0.4rem;
        margin-top: 1rem;
        padding-top: 1rem;
    }

    .pagination-btn {
        padding: 0.4rem 0.75rem;
        font-size: 0.8rem;
    }

    .pagination-info {
        font-size: 0.8rem;
        width: 100%;
        text-align: center;
        order: -1;
        margin-bottom: 0.5rem;
    }
}
