:root {
    --bg-color: #ffffff;
    --text-color: #333333;
    --border-color: #dddddd;
    --primary-color: #4a90e2;
    --primary-color-dark: #357abd;
    --primary-color-rgb: 74, 144, 226;
    --error-color: #ff4444;
    --input-bg: #ffffff;
    --hover-bg: #f5f5f5;
}

@media (prefers-color-scheme: dark) {
    :root {
        --bg-color: #1a1a1a;
        --text-color: #ffffff;
        --border-color: #333333;
        --primary-color: #4a90e2;
        --primary-color-dark: #357abd;
        --primary-color-rgb: 74, 144, 226;
        --error-color: #ff6b6b;
        --input-bg: #2d2d2d;
        --hover-bg: #2d2d2d;
    }
}

body, html {
    margin: 0;
    padding: 0;
    height: 100%;
    /* Use fallback for older browsers */
    min-height: 100vh;
    /* Use dynamic viewport height for newer browsers */
    min-height: 100dvh;
    /* Fallback for very old browsers */
    min-height: -webkit-fill-available;
    overflow: hidden;
    position: relative;
    background: #EEE;
    background-size: cover;
    background-position: center;
}

body {
  font-size: 1rem;
  font-display: swap;
  -webkit-font-smoothing: antialiased;
}

/*To account for safari/mobile browser ui when calculating size of page*/
.viewport {
  display: -ms-flexbox;
  display: flex;
  -ms-flex-align: center;
  align-items: center;
  -ms-flex-pack: center;
  justify-content: center;
  text-align: center;
  margin: auto;
  padding: 0;
  overflow-x: hidden;
  overflow-y: auto;
  position: fixed;
  -webkit-overflow-scrolling: touch;
}

html {
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
  -webkit-font-smoothing: antialiased;
}

.viewport > div {
    max-width: 1200px;
    margin: auto;
}

.background {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transition: opacity 6s ease-in-out;
    z-index: 0;
}

.background-1, .background-2 { opacity: 0; }
.active { opacity: 1; }

.background::after {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 150%, var(--gradient-color, rgba(0, 0, 0, 0.5)), rgba(255, 255, 255, 0) 90%);
  z-index: -1;
  pointer-events: none;
}

/* === UNIVERSAL SHINE EFFECT FOR ALL BUTTONS === */
/* Apply shine effect to all button types except those with existing shine effects */
.btn:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button), 
.action-button:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button), 
#submitButton,
.login-button, .edit-button, .remove-btn,
label[for="fileInput"], /* File input labels (Choose files button) */
.user-avatar, /* User avatar clickable area */
.tab-button, /* Auth modal tabs */
.settings-save-btn, /* Account settings save button */
button:not(.no-shine):not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button),
input[type="submit"], input[type="button"], /* Form inputs styled as buttons */
a.action-button, a.login-button, /* Action links styled as buttons */
.close /* Modal close buttons */ {
    position: relative;
    overflow: hidden;
}

/* Universal shine effect pseudo-element */
.btn:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button)::before, 
.action-button:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button)::before, 
#submitButton::before,
.login-button::before, .edit-button::before, .remove-btn::before,
label[for="fileInput"]::before, /* File input labels */
.user-avatar::before, /* User avatar */
.tab-button::before, /* Auth modal tabs */
.settings-save-btn::before, /* Account settings save button */
button:not(.no-shine):not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button)::before,
input[type="submit"]::before, input[type="button"]::before, /* Form inputs */
a.action-button::before, a.login-button::before, /* Action links */
.close::before /* Modal close buttons */ {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
    z-index: 1;
}

/* Activate shine effect on hover */
.btn:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button):hover::before, 
.action-button:not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button):hover::before, 
#submitButton:hover:not(:disabled)::before,
.login-button:hover::before, .edit-button:hover::before, .remove-btn:hover::before,
label[for="fileInput"]:hover::before, /* File input labels */
.user-avatar:hover::before, /* User avatar */
.tab-button:hover::before, /* Auth modal tabs */
.settings-save-btn:hover::before, /* Account settings save button */
button:not(.no-shine):not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button):hover::before,
input[type="submit"]:hover::before, input[type="button"]:hover::before, /* Form inputs */
a.action-button:hover::before, a.login-button:hover::before, /* Action links */
.close:hover::before /* Modal close buttons */ {
    left: 100%;
}

/* Ensure button text and content stay above the shine effect */
.btn > *, .action-button > *, #submitButton > *,
.login-button > *, .edit-button > *, .remove-btn > *,
label[for="fileInput"] > *, /* File input labels */
.user-avatar > *, /* User avatar content */
.tab-button > *, /* Auth modal tabs */
.settings-save-btn > *, /* Account settings save button */
button:not(.no-shine) > *,
input[type="submit"] > *, input[type="button"] > *, /* Form inputs */
a.action-button > *, a.login-button > *, /* Action links */
.close > * /* Modal close buttons */ {
    position: relative;
    z-index: 2;
}

/* Disabled buttons should not have shine effect */
.btn:disabled::before, .action-button:disabled::before, #submitButton:disabled::before,
.login-button:disabled::before, .edit-button:disabled::before, .remove-btn:disabled::before,
label[for="fileInput"]:disabled::before, /* File input labels */
.settings-save-btn:disabled::before, /* Account settings save button */
button:disabled::before,
input[type="submit"]:disabled::before, input[type="button"]:disabled::before /* Form inputs */ {
    display: none;
}

/* === BUTTONS (shared) === */
.btn, .action-button, #submitButton {
    padding: 12px 28px;
    background: #007bff;
    color: white;
    font-family: 'Segoe UI', sans-serif;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 18px;
    font-weight: 600;
    white-space: normal;
    line-height: 1.2;
}

.btn:hover, .action-button:hover, #submitButton:hover:not(:disabled) {
    background: #0056b3;
    transform: scale(1.05);
}

/* Small button variants */
.global-actions .btn, .global-actions .action-button, .page-actions .btn, .page-actions .action-button {
    padding: 8px 18px;
    font-size: 15px;
    border-radius: 14px;
}

/* Remove button */
.remove-btn {
    background: none;
    border: none;
    color: red;
    font-size: 24px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    text-align: center;
    border-radius: 4px;
    transition: color 0.2s;
}
.remove-btn:hover { color: darkred; }

.preview-container .remove-btn {
    background: #bb6c6c;
    color: #fff;
    padding: 2px 5px;
    font-size: 14px;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 5px;
    margin-top: 10px;
    transition: background 0.3s;
    height: 40px;
}
.preview-container .remove-btn:hover { background: darkred; }

/* Edit button */
.edit-button {
    background: var(--primary-color);
    border: 1px solid rgba(255, 255, 255, 0.2);
    transition: background 0.2s, transform 0.2s;
}
.edit-button:hover { background: var(--primary-color-dark); }
.edit-button.active { 
    background: #28a745; 
    border-color: rgba(255, 255, 255, 0.3);
}
.edit-button.active:hover { background: #218838; }

/* === PRIMARY ACTION BUTTON === */
.action-button.primary-action {
    background: #28a745 !important;
    color: white !important;
    font-weight: 600 !important;
    border: 2px solid #28a745 !important;
    box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3) !important;
    transform: scale(1.05);
    animation: pulse-glow 2s infinite;
}

.action-button.primary-action:hover {
    background: #218838 !important;
    border-color: #218838 !important;
    transform: scale(1.08) !important;
    box-shadow: 0 6px 16px rgba(40, 167, 69, 0.4) !important;
}

.action-button.primary-action:active {
    transform: scale(1.02) !important;
}

/* Subtle pulsing animation for primary action */
@keyframes pulse-glow {
    0%, 100% { 
        box-shadow: 0 4px 12px rgba(40, 167, 69, 0.3);
    }
    50% { 
        box-shadow: 0 4px 16px rgba(40, 167, 69, 0.5);
    }
}

/* === MESSAGES (shared) === */
.error-message {
    color: #dc3545;
    background-color: rgba(220, 53, 69, 0.1);
    padding: 10px;
    border-radius: 6px;
    margin: 10px 0;
    font-size: 14px;
    display: none;
}
.error-message.show {
    display: block;
}
.success-message {
    padding: 12px;
    border-radius: 6px;
    margin: 10px 0;
    background-color: rgba(40, 167, 69, 0.1);
    color: #28a745;
    border: 1px solid #28a745;
    text-align: center;
    opacity: 1;
    transition: opacity 0.3s ease-out;
}

/* === MODALS (shared) === */
.modal {
    display: none;
    position: fixed;
    z-index: 9999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.3s ease-out;
}
.modal.show {
    opacity: 1;
    display: flex !important; /* ADDED !important for testing */
    align-items: center;
    justify-content: center;
}
.modal-content {
    background-color: var(--modal-bg, #fff);
    margin: 10% auto;
    padding: 25px;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    width: 90%;
    max-width: 400px;
    position: relative;
    overflow: hidden;
}
@media (max-width: 600px) {
    .modal {
        align-items: flex-end;
        padding: 0;
    }
    .modal-content {
        margin: 0 15px 20px 15px;
        max-height: 85vh;
        width: calc(100% - 30px);
        border-radius: 20px;
        padding: 20px;
        background-color: var(--modal-bg, #fff);
        transform: translateY(100%);
        box-sizing: border-box;
    }
    .modal.show .modal-content {
        transform: translateY(0);
    }
}

/* Extra small mobile - covers 350-450px range */
@media (max-width: 400px) {
    .modal-content {
        margin: 0 10px 15px 10px;
        max-height: 90vh;
        width: calc(100% - 20px);
        border-radius: 16px;
        padding: 15px;
    }
}
.close {
    position: absolute;
    right: 10px;
    top: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #666666;
    background: none;
    border: none;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
    z-index: 1;
}
.close:hover {
    background-color: #f5f5f5;
    color: #333333;
}

/* === FORMS (shared) === */
.form-group {
    margin-bottom: 15px;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
}
@media (max-width: 600px) {
    .form-group {
        margin-bottom: 12px;
        padding: 0;
    }
}

/* Extra small mobile - covers 350-450px range */
@media (max-width: 400px) {
    .form-group {
        margin-bottom: 10px;
    }
}
.form-group label {
    display: block;
    margin-bottom: 8px;
    color: var(--text-color);
    font-weight: 500;
    font-size: 14px;
}
.form-group input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    background-color: var(--input-bg);
    color: var(--text-color);
    font-size: 15px;
    transition: all 0.2s;
    box-sizing: border-box;
}
@media (max-width: 600px) {
    .form-group input {
        font-size: 16px;
        padding: 12px;
        width: 100%;
        margin: 0;
    }
}

/* Extra small mobile - covers 350-450px range */
@media (max-width: 400px) {
    .form-group input {
        font-size: 15px;
        padding: 10px;
    }
}
.form-group input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Unified scaling system - matches navbar title intervals */
@media (max-width: 685px) {
  /* Medium mobile - match navbar scaling */
  .btn, .action-button, .global-actions .btn, .global-actions .action-button, .page-actions .btn, .page-actions .action-button,
  label[for="fileInput"] {
    font-size: 14px !important;
    padding: 8px 14px !important;
  }
}

@media (max-width: 550px) {
  /* Small-medium mobile - intermediate sizing */
  .btn, .action-button, .global-actions .btn, .global-actions .action-button, .page-actions .btn, .page-actions .action-button,
  label[for="fileInput"] {
    font-size: 13px !important;
    padding: 7px 12px !important;
  }
}

@media (max-width: 450px) {
  /* Small mobile - match navbar scaling, but not too tiny */
  .btn, .action-button, .global-actions .btn, .global-actions .action-button, .page-actions .btn, .page-actions .action-button,
  label[for="fileInput"] {
    font-size: 12.5px !important;
    padding: 7px 11px !important;
  }
}

@media (max-width: 400px) {
  /* Extra small mobile - covers 350-400px range */
  .btn, .action-button, .global-actions .btn, .global-actions .action-button, .page-actions .btn, .page-actions .action-button,
  label[for="fileInput"] {
    font-size: 12px !important;
    padding: 6px 10px !important;
  }
}

/* === ENHANCED SHIMMER EFFECT FOR PREMIUM BUTTONS === */
/* Optional shimmer animation for primary action buttons */
.btn.shimmer, .action-button.shimmer, #submitButton.shimmer,
.login-button.shimmer, .settings-save-btn.shimmer {
    background-size: 200% 100%;
    animation: shimmer 3s ease-in-out infinite;
}

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

/* Enhanced shine effect for buttons with .enhanced-shine class */
.btn.enhanced-shine::before, .action-button.enhanced-shine::before,
.login-button.enhanced-shine::before {
    background: linear-gradient(90deg, 
        transparent, 
        rgba(255,255,255,0.1), 
        rgba(255,255,255,0.3), 
        rgba(255,255,255,0.1), 
        transparent);
    transition: left 0.6s ease-out;
}

.btn.enhanced-shine:hover::before, .action-button.enhanced-shine:hover::before,
.login-button.enhanced-shine:hover::before {
    left: 100%;
}

/* === SPECIAL SHINE EFFECTS FOR SPECIFIC ELEMENTS === */
/* Custom shine for user avatar */
.user-avatar::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.15), transparent);
    border-radius: 50%; /* Match avatar shape */
}

/* Custom shine for close buttons */
.close::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
    border-radius: 50%; /* Match close button shape */
}

/* Enhanced shine for file input button */
label[for="fileInput"]::before {
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.25), transparent);
}

/* === BROWSER COMPATIBILITY AND EDGE CASE HANDLING === */
/* Ensure shine effect works across all browsers */
.btn, .action-button, #submitButton, .login-button, .edit-button, .remove-btn,
label[for="fileInput"], .user-avatar, .tab-button, .settings-save-btn,
button:not(.no-shine):not(.upgrade-btn):not(.current-plan-button):not(.reactivate-button),
input[type="submit"], input[type="button"],
a.action-button, a.login-button, .close {
    /* Improve rendering performance for animations */
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

/* Prevent shine effect on very small buttons */
@media (max-width: 400px) {
    .btn::before, .action-button::before, #submitButton::before,
    .login-button::before, .edit-button::before, .remove-btn::before,
    label[for="fileInput"]::before, .user-avatar::before,
    .tab-button::before, .settings-save-btn::before,
    button:not(.no-shine)::before, input[type="submit"]::before, input[type="button"]::before,
    a.action-button::before, a.login-button::before,
    .close::before {
        transition: left 0.3s; /* Faster animation on mobile */
    }
}

/* High contrast mode compatibility */
@media (prefers-contrast: high) {
    .btn::before, .action-button::before, #submitButton::before,
    .login-button::before, .edit-button::before, .remove-btn::before,
    label[for="fileInput"]::before, .user-avatar::before,
    .tab-button::before, .settings-save-btn::before,
    button:not(.no-shine)::before, input[type="submit"]::before, input[type="button"]::before,
    a.action-button::before, a.login-button::before,
    .close::before {
        background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    }
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .btn::before, .action-button::before, #submitButton::before,
    .login-button::before, .edit-button::before, .remove-btn::before,
    label[for="fileInput"]::before, .user-avatar::before,
    .tab-button::before, .settings-save-btn::before,
    button:not(.no-shine)::before, input[type="submit"]::before, input[type="button"]::before,
    a.action-button::before, a.login-button::before,
    .close::before {
        transition: none;
    }
    
    .btn:hover::before, .action-button:hover::before, #submitButton:hover::before,
    .login-button:hover::before, .edit-button:hover::before, .remove-btn:hover::before,
    label[for="fileInput"]:hover::before, .user-avatar:hover::before,
    .tab-button:hover::before, .settings-save-btn:hover::before,
    button:not(.no-shine):hover::before, input[type="submit"]:hover::before, input[type="button"]:hover::before,
    a.action-button:hover::before, a.login-button:hover::before,
    .close:hover::before {
        left: 0; /* Just show the shine statically */
        opacity: 0.3;
    }
}
