/* Profile Modal Styles */
.profile-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 9999;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.profile-modal-backdrop.show {
    opacity: 1;
}

.profile-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 800px;
    max-height: 90vh;
    background: var(--bg-primary, #ffffff);
    color: var(--text-primary, #2d3748);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    flex-direction: column;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    /* Force light theme variables for better consistency */
    --bg-primary: #ffffff;
    --bg-secondary: #f7fafc;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --border-color: #e2e8f0;
    --border-light: #f0f0f0;
    --accent-color: #667eea;
    --accent-color-dark: #5a67d8;
    --success-color: #10b981;
    --error-color: #ef4444;
}

/* Dark theme support for the modal */
[data-theme="dark"] .profile-modal {
    --bg-primary: #1a202c;
    --bg-secondary: #2d3748;
    --text-primary: #f7fafc;
    --text-secondary: #a0aec0;
    --border-color: #4a5568;
    --border-light: #2d3748;
    --accent-color: #667eea;
    --accent-color-dark: #5a67d8;
    --success-color: #10b981;
    --error-color: #ef4444;
}

.profile-modal.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

/* Header */
.profile-modal-header {
    padding: 24px;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}

.profile-modal-header h2 {
    margin: 0;
    color: var(--text-primary, #2d3748);
    font-size: 24px;
    font-weight: 600;
}

.profile-modal-close {
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: var(--text-secondary, #4a5568);
    padding: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.profile-modal-close:hover {
    background: var(--bg-secondary, #f7fafc);
    color: var(--text-primary, #2d3748);
}

/* Tabs */
.profile-modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    padding: 0 24px;
    flex-shrink: 0;
}

.tab-btn {
    background: none;
    border: none;
    padding: 16px 24px;
    cursor: pointer;
    font-size: 16px;
    font-weight: 500;
    color: var(--text-secondary, #4a5568);
    border-bottom: 2px solid transparent;
    transition: all 0.2s ease;
}

.tab-btn:hover {
    color: white !important; /* White text on hover for better contrast */
}

.tab-btn.active {
    color: var(--accent-color, #667eea);
    border-bottom-color: var(--accent-color, #667eea);
}

/* Fix hover state for active tab to maintain readability */
.tab-btn.active:hover {
    color: white !important; /* White text on blue background for better contrast */
    background: var(--accent-color-dark, #5a67d8); /* Slightly darker blue on hover */
}

/* Content */
.profile-modal-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px; /* Further reduced to maximize space */
}

/* Loading and Error States */
.loading, .error {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
    color: var(--text-secondary, #4a5568);
    font-size: 16px;
}

.error {
    color: var(--error-color, #ef4444);
}

/* Profile Tab */
.profile-info {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 24px;
    align-items: start;
}

.profile-avatar {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--accent-color, #667eea);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    font-weight: 600;
    overflow: hidden;
    position: relative;
}

/* Google profile picture styling */
.profile-avatar-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

/* Fallback initials styling when image fails to load */
.profile-avatar-fallback {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    color: white;
    font-weight: 600;
    background: var(--accent-color, #667eea);
    border-radius: 50%;
    position: absolute;
    top: 0;
    left: 0;
}

/* Text initials styling for non-Google users */
.profile-avatar-text {
    font-size: 32px;
    color: white;
    font-weight: 600;
}

.profile-details {
    display: grid;
    gap: 16px;
}

.profile-field {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

.profile-field:last-child {
    border-bottom: none;
}

.field-label {
    font-weight: 600;
    color: var(--text-primary, #2d3748);
}

.field-value {
    color: var(--text-secondary, #4a5568);
    text-align: right;
}

/* History Tab */
.current-balance {
    background: var(--bg-secondary, #f7fafc);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 24px;
    text-align: center;
}

.current-balance h3 {
    margin: 0 0 12px 0;
    color: var(--text-primary, #2d3748);
    font-size: 18px;
    font-weight: 600;
}

.balance-display {
    font-size: 28px;
    font-weight: 700;
    color: var(--accent-color, #667eea);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.balance-display .credit-icon {
    font-size: 24px;
}

/* Compact version of current balance */
.current-balance.compact {
    padding: 10px 16px;
    margin-bottom: 8px; /* Further reduced to push content up */
    background: linear-gradient(135deg, var(--accent-color, #667eea), var(--accent-color-dark, #5a67d8));
    color: white;
}

.current-balance.compact h3 {
    margin: 0;
    font-size: 20px; /* Increased from 16px for prominence */
    font-weight: 700;
    color: white;
    text-align: center;
}

.history-filters {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    padding: 16px;
    background: var(--bg-secondary, #f7fafc);
    border-radius: 8px;
    align-items: center;
}

/* History controls container */
.history-controls {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 4px; /* Further reduced to push table up */
    background: var(--bg-secondary, #f7fafc);
    padding: 4px 10px; /* Minimal padding to reduce height */
    border-radius: 6px;
}

/* Compact version of history filters */
.history-filters.compact {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    height: 36px; /* Fixed height to match pagination */
    position: relative;
    top: 15px; /* Move down 2 pixels for better visual alignment */
}

/* Inline pagination container */
.history-pagination-inline {
    display: flex;
    align-items: center;
    height: 36px; /* Fixed height to match filter */
}

.history-filters label {
    font-weight: 500;
    color: var(--text-primary, #333);
}

.history-filters select {
    padding: 6px 10px;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 4px;
    background: var(--bg-primary, white);
    color: var(--text-primary, #333);
    font-size: 14px;
    cursor: pointer;
    height: 32px; /* Fixed height for alignment */
}

.history-table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 0; /* Remove bottom margin */
}

/* History tab container - removed scrolling */
.history-tab-container {
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Table wrapper - no scrolling needed */
.history-table-wrapper {
    margin-bottom: 0;
    flex: 1; /* Take remaining space */
    display: flex;
    flex-direction: column;
}

.history-table th,
.history-table td {
    padding: 8px 10px; /* Reduced to make table more compact */
    text-align: left;
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

/* Make table more compact */
.history-table {
    font-size: 14px;
}

.history-table th {
    background: var(--bg-secondary, #f8f9fa);
    font-weight: 600;
    color: var(--text-primary, #333);
    position: sticky;
    top: 0;
}

.history-table td {
    color: var(--text-secondary, #666);
}

.date-time {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.date {
    font-weight: 500;
    color: var(--text-primary, #333);
}

.time {
    font-size: 12px;
    color: var(--text-secondary, #999);
}

.credit-change {
    font-weight: 600;
}

.credit-change.positive {
    color: var(--success-color, #10b981);
}

.credit-change.negative {
    color: var(--error-color, #ef4444);
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin: 0;
}

/* Inline pagination style */
.history-pagination-inline .pagination {
    margin: 0;
    padding: 0;
    background: none;
}

.pagination button {
    padding: 6px 10px; /* Slightly reduced but still clickable */
    border: 1px solid var(--border-color, #e0e0e0);
    background: var(--bg-primary, white);
    color: var(--text-primary, #333);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px; /* Readable size */
    font-weight: 500;
    min-width: 32px; /* Minimum width for number buttons */
    height: 32px; /* Fixed height for alignment */
}

.pagination button:hover:not(:disabled) {
    background: var(--accent-color, #3b82f6);
    color: white;
    border-color: var(--accent-color, #3b82f6);
}

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

.pagination button.active {
    background: var(--accent-color, #3b82f6);
    color: white;
    border-color: var(--accent-color, #3b82f6);
}

/* Settings Tab */
.settings-section {
    margin-bottom: 20px; /* Reduced from 32px */
    padding-bottom: 16px; /* Reduced from 24px */
    border-bottom: 1px solid var(--border-light, #f0f0f0);
}

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

.settings-section h3 {
    margin: 0 0 12px 0; /* Reduced from 16px */
    color: var(--text-primary, #333);
    font-size: 16px; /* Reduced from 18px */
    font-weight: 600;
}

.form-group {
    margin-bottom: 12px; /* Reduced from 16px */
}

.form-group label {
    display: block;
    margin-bottom: 6px; /* Reduced from 8px */
    font-weight: 500;
    color: var(--text-primary, #333);
    font-size: 14px; /* Added smaller font size */
}

.form-group input {
    width: 100%;
    padding: 10px; /* Reduced from 12px */
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    font-size: 15px; /* Reduced from 16px */
    transition: border-color 0.2s ease;
    background: var(--bg-primary, white);
    color: var(--text-primary, #333);
    box-sizing: border-box;
}

.form-group input:focus {
    outline: none;
    border-color: var(--accent-color, #3b82f6);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.btn {
    padding: 10px 20px; /* Reduced from 12px 24px */
    border: none;
    border-radius: 8px;
    font-size: 15px; /* Reduced from 16px */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-block;
    text-decoration: none;
}

.btn-primary {
    background: var(--accent-color, #3b82f6);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-color-dark, #2563eb);
}

.btn-secondary {
    background: var(--bg-secondary, #f8f9fa);
    color: var(--text-primary, #333);
    border: 1px solid var(--border-color, #e0e0e0);
}

.btn-secondary:hover {
    background: var(--border-color, #e0e0e0);
}

.help-text {
    margin-top: 6px; /* Reduced from 8px */
    font-size: 13px; /* Reduced from 14px */
    color: var(--text-secondary, #666);
    line-height: 1.4; /* Reduced from 1.5 */
}

/* Security section styling */
.security-info {
    background: var(--bg-secondary, #f8f9fa);
    padding: 12px; /* Reduced from 16px */
    border-radius: 8px;
    margin-bottom: 12px; /* Reduced from 16px */
    border-left: 4px solid var(--accent-color, #3b82f6);
}

.security-info p {
    margin: 0 0 8px 0;
}

.security-info p:last-child {
    margin-bottom: 0;
}

/* IMPORTANT: Force Reset Password button to be visible on all pages */
.profile-modal .btn-secondary {
    background: var(--bg-secondary, #f8f9fa) !important;
    color: var(--text-primary, #333) !important;
    border: 1px solid var(--border-color, #e0e0e0) !important;
    padding: 12px 24px !important;
    border-radius: 8px !important;
    font-size: 16px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    transition: all 0.2s ease !important;
    display: inline-block !important;
    text-decoration: none !important;
    opacity: 1 !important;
    visibility: visible !important;
}

.profile-modal .btn-secondary:hover {
    background: var(--border-color, #e0e0e0) !important;
    color: var(--text-primary, #333) !important;
}

.security-notice {
    background: #fef3cd;
    border: 1px solid #ffc107;
    border-radius: 8px;
    padding: 16px;
    margin-top: 16px;
}

[data-theme="dark"] .security-notice {
    background: rgba(255, 193, 7, 0.1);
    border-color: rgba(255, 193, 7, 0.3);
}

.security-notice p {
    margin: 0 0 8px 0;
    color: #856404;
    font-weight: 600;
}

[data-theme="dark"] .security-notice p {
    color: #ffc107;
}

.security-notice ul {
    margin: 0;
    padding-left: 20px;
    color: #856404;
}

[data-theme="dark"] .security-notice ul {
    color: #f8d568;
}

.security-notice li {
    margin-bottom: 4px;
    line-height: 1.4;
}

.security-notice li:last-child {
    margin-bottom: 0;
}

/* Responsive Design */
@media (max-width: 768px) {
    .profile-modal {
        width: 95%;
        max-height: 95vh;
        margin: 2.5vh auto;
    }
    
    .profile-modal-header {
        padding: 16px;
    }
    
    .profile-modal-header h2 {
        font-size: 20px;
    }
    
    .profile-modal-content {
        padding: 16px;
    }
    
    .profile-info {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 16px;
    }
    
    .profile-avatar {
        justify-self: center;
    }
    
    .profile-modal-tabs {
        overflow-x: auto;
        padding: 0 16px;
    }
    
    .tab-btn {
        white-space: nowrap;
        min-width: 120px;
        padding: 12px 16px;
    }
    
    .history-table {
        font-size: 13px;
    }
    
    .history-table th,
    .history-table td {
        padding: 8px;
    }
    
    /* Stack controls vertically on mobile */
    .history-controls {
        flex-direction: column;
        gap: 8px;
    }
    
    .history-filters.compact {
        max-width: 100%;
        width: 100%;
    }
    
    .history-pagination-inline {
        width: 100%;
        justify-content: center;
    }
    
    .profile-field {
        flex-direction: column;
        align-items: flex-start;
        gap: 4px;
    }
    
    .field-value {
        text-align: left;
    }
}

@media (max-width: 480px) {
    .profile-modal {
        width: 100%;
        height: 100%;
        max-height: 100vh;
        border-radius: 0;
        top: 0;
        left: 0;
        transform: none;
    }
    
    .profile-modal.show {
        transform: none;
    }
    
    .pagination {
        flex-wrap: wrap;
        gap: 4px;
    }
    
    .pagination button {
        padding: 6px 10px;
        font-size: 12px;
    }
}

/* Animation enhancements */
.profile-modal-content {
    scrollbar-width: thin;
    scrollbar-color: var(--border-color, #e0e0e0) transparent;
}

/* Specific styling for history tab to prevent scrolling */
.profile-modal-content:has(.history-tab-container) {
    overflow-y: hidden; /* Prevent scrolling when history tab is active */
    display: flex;
    flex-direction: column;
}

.profile-modal-content::-webkit-scrollbar {
    width: 6px;
}

.profile-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.profile-modal-content::-webkit-scrollbar-thumb {
    background: var(--border-color, #e0e0e0);
    border-radius: 3px;
}

.profile-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary, #666);
}

/* Theme compatibility - modal follows app theme automatically through CSS variables */

/* Danger Zone Styles */
.danger-zone {
    margin-top: 24px; /* Reduced from 48px */
    border: 1px solid var(--error-color, #dc3545) !important; /* Added !important to ensure border shows */
    border-radius: 8px;
    background-color: var(--bg-secondary, #f8f9fa);
    overflow: hidden; /* Ensure content doesn't overflow and hide border */
}

.danger-title {
    color: var(--error-color, #dc3545);
    margin: 0;
    padding: 12px 16px; /* Reduced from 16px 20px */
    border-bottom: 1px solid var(--border-color, #e2e8f0);
    font-size: 1rem; /* Reduced from 1.1rem */
    font-weight: 600;
}

.danger-content {
    padding: 16px; /* Reduced from 20px */
}

.danger-warning {
    color: var(--text-primary, #2d3748);
    background-color: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e2e8f0);
    padding: 10px 14px; /* Reduced from 12px 16px */
    border-radius: 4px;
    margin-bottom: 12px; /* Reduced from 16px */
    font-weight: 500;
    font-size: 14px; /* Added smaller font size */
}

[data-theme="dark"] .danger-warning {
    background-color: var(--bg-secondary, #2d3748);
    border-color: var(--border-color, #4a5568);
}

.danger-info {
    margin: 16px 0 8px 0;
    font-weight: 500;
    color: var(--text-primary, #2d3748);
}

.danger-list {
    margin: 8px 0 20px 20px;
    color: var(--text-secondary, #4a5568);
}

.danger-list li {
    margin: 4px 0;
}

.btn-danger {
    background-color: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.2s;
}

.btn-danger:hover {
    background-color: #c82333;
}

.btn-danger:disabled {
    background-color: #e47682;
    cursor: not-allowed;
}

/* Delete Account Modal Styles */
.delete-account-backdrop {
    background-color: rgba(0, 0, 0, 0.7);
}

.delete-account-modal .danger-header {
    background-color: #dc3545;
    color: white;
}

.delete-account-modal .danger-header h2 {
    color: white;
}

/* Form error styles for delete account modal */
.delete-account-modal .form-error {
    color: var(--error-color, #dc3545);
    font-size: 0.875rem;
    margin-top: 0.25rem;
    display: none;
    animation: errorSlideIn 0.3s ease;
}

.delete-account-modal .form-error.show {
    display: block;
}

/* Invalid input styles for delete account modal */
.delete-account-modal .form-control.is-invalid {
    border-color: var(--error-color, #dc3545);
    animation: shake 0.3s ease-in-out;
}

@keyframes errorSlideIn {
    0% {
        opacity: 0;
        transform: translateY(-10px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

/* Loading overlay for delete account modal */
.delete-account-modal .loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 10003;
    backdrop-filter: blur(8px);
    flex-direction: column;
    gap: 1rem;
    border-radius: 16px;
}

.delete-account-modal .loading-overlay.show {
    display: flex;
}

.delete-account-modal .loading-overlay .loading-spinner {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.delete-account-modal .loading-overlay p {
    color: white;
    font-size: 1.1rem;
    font-weight: 500;
    margin: 0;
    text-align: center;
}

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

.danger-notice {
    background-color: rgba(220, 53, 69, 0.1);
    color: var(--error-color, #dc3545);
    padding: 16px;
    border-radius: 4px;
    border: 1px solid var(--error-color, #dc3545);
    margin-bottom: 16px;
}

.danger-notice p {
    margin: 0;
    font-weight: 600;
}

.delete-warning {
    background-color: var(--bg-secondary, #f8f9fa);
    border: 1px solid var(--border-color, #e2e8f0);
    padding: 16px;
    border-radius: 4px;
    margin-top: 20px;
}

[data-theme="dark"] .delete-warning {
    background-color: var(--bg-secondary, #2d3748);
    border-color: var(--border-color, #4a5568);
}

.delete-warning p {
    margin: 0 0 8px 0;
    font-weight: 600;
    color: var(--text-primary, #2d3748);
}

.delete-warning ul {
    margin: 0 0 0 20px;
    padding: 0;
    color: var(--text-secondary, #4a5568);
}

.delete-warning li {
    margin: 4px 0;
} 