/* Professional Mobile Theme for Cash Control */
/* Mobile-first design with modern card-based layout */

/* Import modern font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

/* Base mobile styles */
@media (max-width: 768px) {
    * {
        box-sizing: border-box;
    }
    
    body {
        font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
        background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        margin: 0;
        padding: 0;
        min-height: 100vh;
        font-size: 16px;
        line-height: 1.5;
    }

    /* FORCE OVERRIDE: Fix vertical text issue by overriding base CSS */
    table#transactions-table,
    table#transactions-table thead,
    table#transactions-table tbody,
    table#transactions-table th,
    table#transactions-table td,
    table#transactions-table tr {
        display: initial !important;
    }

    /* Container adjustments for mobile */
    .container {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        background: transparent !important;
        min-height: 100vh;
    }

    /* Header redesign - vertical stack */
    .header-bar {
        background: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(10px);
        padding: 10px 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        position: sticky;
        top: 0;
        z-index: 100;
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        min-height: auto !important;
    }
    
    /* Top row: Sheet selector and logout */
    .header-bar .sheet-actions {
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        gap: 8px;
        order: 1;
        width: 100% !important;
        padding: 0 12px !important;
    }
    
    /* Search bar - full width below sheet */
    .header-bar #search {
        flex: 1 !important;
        order: 2;
        width: 100% !important;
        margin: 0 !important;
        padding: 10px 12px !important;
        border: none !important;
        border-top: 1px solid #f0f0f0 !important;
        border-bottom: 1px solid #f0f0f0 !important;
        border-radius: 0 !important;
        font-size: 14px !important;
        background: #fafafa !important;
        transition: all 0.3s ease;
        box-shadow: none !important;
        height: 40px !important;
        max-height: 40px !important;
        line-height: normal !important;
    }
    
    .header-bar #search:focus {
        background: #ffffff !important;
        border-color: #e1e5e9 !important;
    }
    
    /* Logout button in top row with sheet */
    .header-bar .logout-button {
        order: 1;
    }

    .header-bar #search:focus {
        border-color: #2e7d32;
        outline: none;
        box-shadow: 0 0 0 2px rgba(46, 125, 50, 0.1);
    }

    .sheet-actions select {
        padding: 10px 12px !important;
        border: 1px solid #e1e5e9 !important;
        border-radius: 8px !important;
        background: white !important;
        font-size: 14px !important;
        flex: 1 !important;
        height: 40px !important;
        max-height: 40px !important;
    }

    .sheet-actions a {
        display: none !important;
    }

    .logout-button {
        background: linear-gradient(45deg, #ff6b6b, #ff8e53) !important;
        color: white !important;
        border: none !important;
        padding: 10px 16px !important;
        border-radius: 8px !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        box-shadow: 0 2px 6px rgba(255, 107, 107, 0.3);
        flex-shrink: 0;
        height: 40px !important;
        white-space: nowrap;
    }

    /* Summary cards - modern card design */
    .summary-cards {
        padding: 16px;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        grid-template-rows: auto auto auto !important;
        gap: 12px !important;
        margin-bottom: 0 !important;
    }

    .summary-card {
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px);
        border: none !important;
        border-radius: 12px !important;
        padding: 16px !important;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.08) !important;
        text-align: center !important;
        transition: all 0.3s ease;
        position: relative;
        overflow: hidden;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
    }

    .summary-card::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        right: 0;
        height: 4px;
        background: linear-gradient(90deg, #2e7d32, #4caf50);
        opacity: 0;
        transition: opacity 0.3s ease;
    }

    .summary-card:hover::before {
        opacity: 1;
    }

    .summary-card.cash-in::before {
        background: linear-gradient(90deg, #2e7d32, #66bb6a);
    }

    .summary-card.cash-out::before {
        background: linear-gradient(90deg, #d32f2f, #f44336);
    }

    .summary-card.net-balance::before {
        background: linear-gradient(90deg, #1976d2, #42a5f5);
    }

    .summary-label {
        font-size: 11px !important;
        font-weight: 600 !important;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        margin-bottom: 6px !important;
        opacity: 0.8;
        text-align: center !important;
    }

    .summary-value {
        font-size: 1.8em !important;
        font-weight: 700 !important;
        margin: 0;
        text-align: center !important;
    }
    
    /* Balance card spans 2 columns */
    .summary-card.net-balance {
        grid-column: 1 / -1 !important;
    }

    /* Action buttons - spanning full width */
    .summary-buttons {
        grid-column: 1 / -1 !important;
        display: grid !important;
        grid-template-columns: 1fr 1fr !important;
        gap: 12px !important;
        margin-top: 8px;
    }

    .summary-buttons button {
        padding: 16px 20px !important;
        border-radius: 12px !important;
        border: none !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        text-transform: uppercase;
        letter-spacing: 0.5px;
        transition: all 0.3s ease;
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        position: relative;
        overflow: hidden;
    }

    .add-in {
        background: linear-gradient(135deg, #2e7d32, #4caf50) !important;
        color: white !important;
    }

    .add-in:active {
        transform: translateY(2px);
        box-shadow: 0 2px 8px rgba(46, 125, 50, 0.3);
    }

    .add-out {
        background: linear-gradient(135deg, #d32f2f, #f44336) !important;
        color: white !important;
    }

    .add-out:active {
        transform: translateY(2px);
        box-shadow: 0 2px 8px rgba(211, 47, 47, 0.3);
    }

    /* Table section - card based */
    .table-section {
        margin: 20px;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px);
        border-radius: 16px !important;
        overflow: hidden;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
    }

    .table-meta {
        padding: 16px 20px !important;
        background: rgba(248, 249, 250, 0.8);
        border-bottom: 1px solid rgba(0, 0, 0, 0.05);
        display: flex !important;
        justify-content: space-between !important;
        align-items: center !important;
        flex-wrap: wrap !important;
        gap: 8px;
    }

    .table-meta span {
        font-size: 13px;
        color: #6c757d;
        font-weight: 500;
    }

    .table-pagination button {
        background: #f8f9fa !important;
        border: 1px solid #dee2e6 !important;
        padding: 6px 12px !important;
        border-radius: 6px !important;
        font-size: 14px !important;
        color: #495057;
        min-width: 44px;
    }

    .table-pagination button:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

    /* Mobile transaction cards instead of table */
    #transactions-table {
        display: block !important;
        width: 100% !important;
        border-spacing: 0 !important;
    }

    #transactions-table thead {
        display: none !important;
    }
    
    #transactions-table thead th {
        display: none !important;
    }

    #transactions-table tbody {
        display: block !important;
        padding: 0 !important;
        width: 100% !important;
    }

    #transactions-table tbody tr {
        display: flex !important;
        align-items: flex-start !important;
        justify-content: space-between !important;
        width: 100% !important;
        margin: 0 0 8px 0 !important;
        background: #ffffff !important;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        border: none !important;
        position: relative;
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        overflow: visible !important;
        min-height: 68px !important;
        padding: 12px !important;
        flex-wrap: wrap !important;
        gap: 6px !important;
        box-sizing: border-box !important;
    }
    
    #transactions-table tbody tr:active {
        transform: scale(0.98);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    #transactions-table tr::before {
        content: '';
        position: absolute;
        top: 0;
        left: 0;
        width: 4px;
        height: 100%;
        background: transparent;
        transition: all 0.2s ease;
        border-radius: 12px 0 0 12px;
    }

    #transactions-table tr:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
    }

    /* Add visual indicators based on transaction type */
    #transactions-table tr:has(.amount-in)::before {
        background: linear-gradient(180deg, #2e7d32, #4caf50);
    }

    #transactions-table tr:has(.amount-out)::before {
        background: linear-gradient(180deg, #d32f2f, #f44336);
    }

    #transactions-table td {
        display: inline-block !important;
        border: none !important;
        padding: 0 !important;
        margin: 0 !important;
        position: relative;
        vertical-align: middle;
        text-align: left !important;
        box-sizing: border-box !important;
    }

    /* Hide checkbox column completely */
    #transactions-table td:first-child,
    #transactions-table th:first-child {
        display: none !important;
    }

    /* Hide date column on mobile */
    #transactions-table td:nth-child(2) {
        display: none !important;
    }

    /* Description cell - left side */
    #transactions-table td:nth-child(3) {
        flex: 1 1 auto !important;
        display: inline-flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        justify-content: flex-start !important;
        padding: 0 !important;
        margin: 0 !important;
        font-size: 15px;
        font-weight: 500;
        color: #212529 !important;
        line-height: 1.5;
        white-space: normal !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
        min-width: 0;
        max-width: calc(100% - 110px) !important;
        width: calc(100% - 110px) !important;
    }
    
    #transactions-table td:nth-child(3) .description-text {
        color: #212529 !important;
    }
    
    /* Date will be shown in a span inside the description cell */
    #transactions-table td:nth-child(3) .transaction-date-mobile {
        font-size: 11px;
        color: #6c757d !important;
        font-weight: 400;
        margin-top: 2px;
        display: block;
    }

    /* Amount cell - right side */
    #transactions-table td:nth-child(4) {
        display: inline-flex !important;
        align-items: flex-start !important;
        justify-content: flex-end !important;
        flex-shrink: 0 !important;
        padding: 0 !important;
        margin: 0 !important;
        white-space: nowrap !important;
        min-width: 100px !important;
        width: 100px !important;
        text-align: right;
    }

    #transactions-table td:nth-child(4) .amount-in {
        font-size: 18px;
        font-weight: 700;
        color: #2e7d32 !important;
    }

    #transactions-table td:nth-child(4) .amount-out {
        font-size: 18px;
        font-weight: 700;
        color: #d32f2f !important;
    }

    /* Show balance on mobile in compact format */
    #transactions-table td:nth-child(5) {
        display: inline-block !important;
        font-size: 12px !important;
        color: #495057 !important;
        font-weight: 600 !important;
        padding: 0 !important;
        margin: 2px 0 0 0 !important;
        width: 100% !important;
        text-align: left !important;
    }
    
    #transactions-table td:nth-child(5)::before {
        content: 'Balance: ';
        font-weight: 400;
        color: #6c757d !important;
    }

    /* Show actions visible on mobile */
    #transactions-table td:nth-child(6) {
        display: inline-flex !important;
        gap: 6px !important;
        align-items: center !important;
        justify-content: flex-end !important;
        width: 100% !important;
        margin-top: 6px !important;
        padding: 0 !important;
    }
    
    /* Style action buttons for mobile */
    #transactions-table td:nth-child(6) button {
        padding: 6px 12px !important;
        font-size: 12px !important;
        border-radius: 6px !important;
        border: none !important;
        min-height: 32px !important;
        font-weight: 500 !important;
    }
    
    #transactions-table td:nth-child(6) .edit-button {
        background: rgba(33, 150, 243, 0.15) !important;
        color: #1976d2 !important;
    }
    
    #transactions-table td:nth-child(6) .delete-button {
        background: rgba(244, 67, 54, 0.15) !important;
        color: #d32f2f !important;
    }

    /* Remove all pseudo-element labels for clean mobile layout */
    #transactions-table td::before,
    #transactions-table td:nth-child(1)::before,
    #transactions-table td:nth-child(2)::before,
    #transactions-table td:nth-child(3)::before,
    #transactions-table td:nth-child(4)::before,
    #transactions-table td:nth-child(5)::before,
    #transactions-table td:nth-child(6)::before,
    #transactions-table td:nth-child(7)::before {
        display: none !important;
        content: none !important;
    }

    /* Ensure description text flows normally */
    #transactions-table td:nth-child(3) * {
        white-space: normal !important;
        word-break: normal !important;
        writing-mode: horizontal-tb !important;
        text-orientation: mixed !important;
    }

    /* Overlay improvements */
    .overlay-content {
        width: calc(100% - 40px) !important;
        max-width: none !important;
        margin: 20px !important;
        border-radius: 16px !important;
        padding: 24px !important;
        box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3) !important;
    }

    .overlay-content h2 {
        font-size: 20px !important;
        font-weight: 700 !important;
        margin-bottom: 20px !important;
        color: #212529;
    }

    .overlay-content form {
        gap: 16px !important;
    }

    .overlay-content input,
    .overlay-content select {
        padding: 12px 16px !important;
        border: 2px solid #e1e5e9 !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        background: white;
    }

    .overlay-content input:focus,
    .overlay-content select:focus {
        border-color: #2e7d32 !important;
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(46, 125, 50, 0.1) !important;
    }

    .overlay-content button {
        padding: 12px 20px !important;
        border-radius: 8px !important;
        font-size: 16px !important;
        font-weight: 600 !important;
        border: none !important;
    }

    .overlay-content button[type="submit"] {
        background: linear-gradient(135deg, #2e7d32, #4caf50) !important;
        color: white !important;
    }

    .overlay-content button[type="button"] {
        background: #f8f9fa !important;
        color: #495057 !important;
    }

    /* Offline indicator */
    .offline-indicator {
        background: linear-gradient(135deg, #ff6b6b, #ff8e53) !important;
        font-weight: 600;
        font-size: 14px;
    }

    /* Form improvements */
    #transaction-form {
        margin: 20px !important;
        background: rgba(255, 255, 255, 0.95) !important;
        backdrop-filter: blur(10px);
        border-radius: 16px !important;
        padding: 20px !important;
        box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1) !important;
    }

    #transaction-form input,
    #transaction-form select {
        padding: 12px 16px !important;
        border: 2px solid #e1e5e9 !important;
        border-radius: 8px !important;
        font-size: 16px !important;
    }

    #transaction-form button {
        padding: 12px 20px !important;
        border-radius: 8px !important;
        font-weight: 600 !important;
    }

    /* Add visual feedback for touch */
    button:active {
        transform: scale(0.98);
    }

    .action-btn {
        transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
        border-radius: 8px !important;
        padding: 8px 10px !important;
        margin: 0 2px;
    }

    .edit-btn:hover {
        background: rgba(33, 150, 243, 0.1) !important;
    }

    .delete-btn:hover {
        background: rgba(244, 67, 54, 0.1) !important;
    }

    .transfer-btn:hover {
        background: rgba(255, 193, 7, 0.1) !important;
    }

    /* Improve focus indicators for accessibility */
    button:focus,
    input:focus,
    select:focus {
        outline: 2px solid #2e7d32;
        outline-offset: 2px;
    }

    /* Smooth page transitions */
    body {
        transition: background 0.3s ease;
    }

    /* Enhanced loading animation */
    .transaction-row {
        animation: slideInUp 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    @keyframes slideInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    /* Staggered animation for multiple rows */
    .transaction-row:nth-child(1) { animation-delay: 0.05s; }
    .transaction-row:nth-child(2) { animation-delay: 0.1s; }
    .transaction-row:nth-child(3) { animation-delay: 0.15s; }
    .transaction-row:nth-child(4) { animation-delay: 0.2s; }
    .transaction-row:nth-child(5) { animation-delay: 0.25s; }

    /* Success/Error toast notifications */
    .toast {
        position: fixed;
        bottom: 100px;
        left: 50%;
        transform: translateX(-50%) translateY(20px);
        background: rgba(46, 125, 50, 0.95);
        backdrop-filter: blur(10px);
        color: white;
        padding: 14px 24px;
        border-radius: 30px;
        font-weight: 500;
        font-size: 14px;
        z-index: 1000;
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
        max-width: 80%;
        text-align: center;
    }

    .toast.show {
        opacity: 1;
        visibility: visible;
        transform: translateX(-50%) translateY(0);
    }

    .toast.error {
        background: rgba(211, 47, 47, 0.95);
    }
    
    .toast.info {
        background: rgba(33, 150, 243, 0.95);
    }
    
    .toast.warning {
        background: rgba(255, 152, 0, 0.95);
    }

    /* Skeleton loading for better perceived performance */
    .skeleton {
        background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
        background-size: 200% 100%;
        animation: loading 1.5s infinite;
    }

    @keyframes loading {
        0% { background-position: 200% 0; }
        100% { background-position: -200% 0; }
    }

    /* Loading states */
    .loading {
        position: relative;
        pointer-events: none;
        opacity: 0.7;
    }

    .loading::after {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 20px;
        height: 20px;
        margin: -10px 0 0 -10px;
        border: 2px solid #f3f3f3;
        border-top: 2px solid #2e7d32;
        border-radius: 50%;
        animation: spin 1s linear infinite;
    }

    @keyframes spin {
        0% { transform: rotate(0deg); }
        100% { transform: rotate(360deg); }
    }

    /* Empty state styling */
    .empty-state {
        text-align: center !important;
        padding: 80px 30px !important;
        color: #6c757d;
        background: rgba(255, 255, 255, 0.95) !important;
        border-radius: 16px;
        backdrop-filter: blur(10px);
    }

    .empty-state h3 {
        font-size: 20px !important;
        font-weight: 600 !important;
        margin-bottom: 12px !important;
        color: #495057 !important;
    }

    .empty-state p {
        font-size: 15px !important;
        margin-bottom: 24px !important;
        opacity: 0.8;
    }

    .empty-state .empty-icon {
        font-size: 64px !important;
        margin-bottom: 20px !important;
        opacity: 0.6;
        animation: float 3s ease-in-out infinite;
    }
    
    @keyframes float {
        0%, 100% { transform: translateY(0); }
        50% { transform: translateY(-10px); }
    }

    /* Quick action floating button */
    .fab {
        position: fixed;
        bottom: 80px;
        right: 24px;
        width: 60px;
        height: 60px;
        border-radius: 50%;
        background: linear-gradient(135deg, #2e7d32, #4caf50);
        color: white;
        border: none;
        box-shadow: 0 8px 24px rgba(46, 125, 50, 0.4);
        cursor: pointer;
        display: none; /* Hidden for now, can be enabled */
        align-items: center;
        justify-content: center;
        font-size: 28px;
        z-index: 50;
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .fab:hover {
        transform: scale(1.1);
        box-shadow: 0 12px 32px rgba(46, 125, 50, 0.5);
    }

    .fab:active {
        transform: scale(0.95);
    }
    
    /* Quick action menu for FAB */
    .fab-menu {
        position: fixed;
        bottom: 150px;
        right: 24px;
        display: none;
        flex-direction: column;
        gap: 12px;
        z-index: 49;
    }
    
    .fab-menu.active {
        display: flex;
    }
    
    .fab-menu button {
        width: 48px;
        height: 48px;
        border-radius: 50%;
        border: none;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        font-size: 20px;
        cursor: pointer;
        transition: all 0.2s ease;
    }
    
    .fab-menu .fab-in {
        background: linear-gradient(135deg, #2e7d32, #4caf50);
        color: white;
    }
    
    .fab-menu .fab-out {
        background: linear-gradient(135deg, #d32f2f, #f44336);
        color: white;
    }

    /* Pull to refresh indicator */
    .pull-to-refresh {
        height: 60px;
        display: flex;
        align-items: center;
        justify-content: center;
        background: rgba(255, 255, 255, 0.95);
        margin: 20px;
        border-radius: 12px;
        color: #6c757d;
        font-size: 14px;
        transform: translateY(-100px);
        opacity: 0;
        transition: all 0.3s ease;
    }

    .pull-to-refresh.show {
        transform: translateY(0);
        opacity: 1;
    }

    /* Swipe actions hint */
    .swipe-hint {
        position: absolute;
        top: 50%;
        right: 20px;
        transform: translateY(-50%);
        opacity: 0.3;
        font-size: 12px;
        color: #6c757d;
        pointer-events: none;
    }
}

/* Tablet adjustments */
@media (min-width: 769px) and (max-width: 1024px) {
    .container {
        max-width: 95% !important;
        margin: 20px auto !important;
        border-radius: 12px !important;
    }
    
    .summary-cards {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Landscape phone adjustments */
@media (max-width: 768px) and (orientation: landscape) {
    .summary-cards {
        grid-template-columns: repeat(4, 1fr) !important;
        grid-template-rows: auto !important;
        padding: 12px 20px;
    }
    
    .summary-buttons {
        grid-column: 1 / -1 !important;
        margin-top: 12px;
    }
}



