:root {
  --color-primary: #0069C7;
  --color-primary-hover: #0054A3;
  --color-primary-disabled: #338ADF;
  --color-secondary: #2E8F2F;
  --color-secondary-hover: #247425; /* Added hover for secondary */
  --color-secondary-bg-panel: rgba(46, 143, 47, 0.1); /* Green panel bg */
  --color-accent: #FFC627;
  --color-accent-hover: #F0B90B; /* Added hover for accent */
  --color-text-main: #1B1B1B;
  --color-text-secondary: #4D4D4D;
  --color-bg: #FFFFFF;
  --color-bg-section: #F5F7FA;
  --color-border: #E1E4E8;
  --color-error: #D93025; /* Added error color */
  --color-success: var(--color-secondary); /* Use secondary green for success */
  
  /* Sidebar specific colors */
  --color-bg-dark: #2c3e50;
  --color-bg-hover: #f5f5f5;
  --color-bg-hover-dark: #4a5568;
  --color-text: #1B1B1B;
  --color-text-light: #a0aec0;
  --color-text-light-hover: #e2e8f0;
  --color-primary-dark: #0056b3;

  --font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
  --border-radius: 4px;
  --spacing-unit: 8px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --color-primary: #4796F5;
    --color-primary-hover: #6CAEFF; /* Adjusted dark hover */
    --color-primary-disabled: #2A5D9A; /* Adjusted dark disabled */
    --color-secondary: #59B55B;
    --color-secondary-hover: #72C774; /* Adjusted dark hover */
    --color-secondary-bg-panel: rgba(89, 181, 91, 0.15); /* Adjusted dark panel bg */
    --color-accent: #FFD866;
    --color-accent-hover: #FFE082; /* Adjusted dark hover */
    --color-text-main: #F1F3F4;
    --color-text-secondary: #9AA0A6;
    --color-bg: #111315;
    --color-bg-section: #1C1E22;
    --color-border: #303134;
    --color-error: #F28B82; /* Adjusted dark error */
    /* Success remains the same green tint */
    
    /* Dark mode sidebar colors */
    --color-bg-dark: #1a202c;
    --color-bg-hover: #2d3748;
    --color-bg-hover-dark: #4a5568;
    --color-text: #F1F3F4;
    --color-text-light: #718096;
    --color-text-light-hover: #e2e8f0;
    --color-primary-dark: #2b6cb0;
  }
}

/* --- Global Styles --- */
body {
  font-family: var(--font-family);
  background-color: var(--color-bg);
  color: var(--color-text-main);
  margin: 0;
  /* padding: calc(var(--spacing-unit) * 2); */ /* Removed for full width */
  line-height: 1.6;
  display: flex; /* Keep flex for potential future direct body children if any, or remove if not needed */
  flex-direction: column;
  /* align-items: center; */ /* Removed for full width */
}

#app-container {
  background-color: var(--color-bg); /* Match body or be transparent if children cover it */
  /* padding: calc(var(--spacing-unit) * 3); */ /* Removed for full width */
  /* border-radius: var(--border-radius); */ /* Removed for full width */
  /* border: 1px solid var(--color-border); */ /* Removed for full width */
  /* max-width: 800px; */ /* Removed for full width */
  width: 100%; /* Ensured by 100vw in index.css, but can keep for clarity */
  /* box-shadow: 0 2px 4px rgba(0,0,0,0.05); */ /* Removed for full width */
  /* Styles from index.css will now primarily define #app-container's layout (flex, row, 100vw, 100vh) */
}

@media (prefers-color-scheme: dark) {
  #app-container {
    /* box-shadow: 0 2px 4px rgba(0,0,0,0.2); */ /* Removed for full width */
    background-color: var(--color-bg); /* Match body or be transparent */
  }
}

h1 { /* Common h1, though may be overridden */
  color: var(--color-primary);
  text-align: center;
  margin-bottom: calc(var(--spacing-unit) * 3);
}

label { /* Common label, though may be overridden */
  display: block;
  margin-bottom: var(--spacing-unit);
  color: var(--color-text-secondary);
  font-weight: 600;
}

/* Style for the actual hidden file input */
input[type="file"] {
  display: none;
}

/* --- Utility Classes & Common Elements --- */

/* --- Icon Button --- */
.icon-button {
  background: none;
  border: none;
  cursor: pointer;
  padding: var(--spacing-unit);
  color: var(--color-text-secondary);
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s ease, color 0.2s ease;
}

.icon-button:hover {
  background-color: var(--color-bg-section);
  color: var(--color-text-main);
}

/* Primary button (used in settings, matches generate button) */
.primary-button {
  background-color: var(--color-primary);
  color: white;
  padding: calc(var(--spacing-unit) * 1.5) calc(var(--spacing-unit) * 3);
  border: none;
  border-radius: var(--border-radius);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.2s ease;
  width: 100%;
}

.primary-button:hover {
  background-color: var(--color-primary-hover);
}

.primary-button:disabled {
  background-color: var(--color-primary-disabled);
  cursor: not-allowed;
}

/* Secondary button style */
.secondary-button {
    padding: 8px 16px;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.secondary-button:hover {
    background-color: var(--color-bg-section);
    color: var(--color-text-main);
}

.danger-button {
    background-color: var(--color-error);
    color: white;
    border: 1px solid var(--color-error);
}
.danger-button:hover {
    background-color: #B00020; /* Darker error color */
    border-color: #B00020;
}

/* --- Status Message --- */
/* Base style for status message area */
#status-message {
    margin-top: var(--spacing-unit);
    padding: var(--spacing-unit);
    border-radius: var(--border-radius);
    text-align: center;
    font-size: 0.9rem;
    min-height: 1.5em; /* Prevent layout shifts */
    /* Alternative specific status styles below might be preferred */
}

/* General status types */
.status-error, #status-message.error {
    background-color: rgba(217, 48, 37, 0.1); /* Original .status-error */
    color: var(--color-error);
    border: 1px solid var(--color-error);
    padding: 8px 12px; /* from #status-message.error */
    margin: 12px 0; /* from #status-message.error */
    border-radius: 4px; /* from #status-message.error */
    text-align: center; /* from #status-message.error */
}
/* Ensure specificity if both classes are used, or choose one system */
#status-message.error { 
    background-color: #ffebee; /* from #status-message.error */
    color: #c62828; /* from #status-message.error */
}


.status-success, #status-message.success {
    background-color: var(--color-secondary-bg-panel); /* Original .status-success */
    color: var(--color-secondary);
    border: 1px solid var(--color-secondary);
    padding: 8px 12px; /* from #status-message.success */
    margin: 12px 0; /* from #status-message.success */
    border-radius: 4px; /* from #status-message.success */
    text-align: center; /* from #status-message.success */
}
#status-message.success {
    background-color: #e8f5e9; /* from #status-message.success */
    color: #2e7d32; /* from #status-message.success */
}

#status-message.info {
    background-color: #e3f2fd;
    color: #1565c0;
    padding: 8px 12px;
    margin: 12px 0;
    border-radius: 4px;
    text-align: center;
}


/* Help Text */
.help-text {
  font-size: 0.8rem;
  color: var(--color-text-secondary);
  margin-top: calc(var(--spacing-unit));
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    width: 100%;
}

.spinner-inner {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(0, 0, 0, 0.1);
    border-radius: 50%;
    border-top-color: var(--color-primary);
    animation: spin 1s ease-in-out infinite;
    margin-bottom: 1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Dark mode support for spinner */
@media (prefers-color-scheme: dark) {
    .spinner-inner {
        border-color: rgba(255, 255, 255, 0.1);
        border-top-color: var(--color-primary);
    }
}

.body-modal-open {
    overflow: hidden; /* Prevent background scroll when any modal is open */
}

/* Ensure modals are above other content - General modal z-index, might be overridden by specific modals */
.modal {
    z-index: 1000; 
}

/* Credits Widget in Classic Header */
.header-actions #credits-widget-container {
    position: relative;
    margin-right: 12px;
}

.header-actions #credits-widget-container .credits-widget {
    display: flex;
    align-items: center;
    background-color: var(--color-bg-section);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    padding: 8px 12px;
    font-size: 0.9rem;
    color: var(--color-text-main);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 80px;
    justify-content: center;
}

.header-actions #credits-widget-container .credits-widget:hover {
    background-color: var(--color-bg-hover, #f0f0f0);
    border-color: var(--color-primary);
}

.header-actions #credits-widget-container .credits-balance {
    font-weight: 600;
    color: var(--color-primary);
    margin-left: 4px;
}

.header-actions #credits-widget-container .credits-icon {
    font-size: 1rem;
    margin-right: 4px;
}

.header-actions #credits-widget-container .credits-dropdown {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: var(--color-bg);
    border: 1px solid var(--color-border);
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    min-width: 280px;
    z-index: 1001;
    display: none;
    margin-top: 4px;
}

.header-actions #credits-widget-container .credits-dropdown.show {
    display: block;
}

.header-actions #credits-widget-container .credits-dropdown .dropdown-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--color-border);
    font-weight: 600;
    color: var(--color-text-main);
}

.header-actions #credits-widget-container .credits-dropdown .dropdown-section {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.header-actions #credits-widget-container .credits-dropdown .dropdown-section:last-child {
    border-bottom: none;
}

.header-actions #credits-widget-container .credits-dropdown .dropdown-item {
    padding: 8px 16px;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 0.9rem;
    color: var(--color-text-main);
}

.header-actions #credits-widget-container .credits-dropdown .dropdown-item:hover {
    background-color: var(--color-bg-hover, #f0f0f0);
}

.header-actions #credits-widget-container .credits-dropdown .transaction-item {
    padding: 8px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--color-text-secondary);
}

.header-actions #credits-widget-container .credits-dropdown .transaction-amount {
    font-weight: 600;
    color: var(--color-primary);
}

.header-actions #credits-widget-container .credits-dropdown .transaction-amount.negative {
    color: var(--color-error, #e74c3c);
}

.header-actions #credits-widget-container .credits-dropdown .transaction-amount.positive {
    color: var(--color-success, #27ae60);
}

.header-actions #credits-widget-container .credits-dropdown .buy-credits-btn {
    margin: 8px 16px;
    padding: 8px 16px;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: var(--border-radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: background-color 0.2s ease;
}

.header-actions #credits-widget-container .credits-dropdown .buy-credits-btn:hover {
    background-color: var(--color-primary-dark, #005bb5);
}

/* Mobile adjustments for credits widget */
@media (max-width: 768px) {
    .header-actions #credits-widget-container {
        margin-right: 8px;
    }
    
    .header-actions #credits-widget-container .credits-widget {
        padding: 6px 8px;
        font-size: 0.8rem;
        min-width: 60px;
    }
    
    .header-actions #credits-widget-container .credits-dropdown {
        min-width: 240px;
        right: -10px;
    }
}

/* Credits Widget Pulse Animation */
@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(59, 130, 246, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0);
    }
}

/* Expensive Action Confirmation Modal */
.expensive-action-confirmation-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10002;
}

.expensive-action-confirmation-modal .modal-content {
    background: white;
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
    overflow: hidden;
}

.expensive-action-confirmation-modal .modal-header {
    background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    color: white;
    padding: 20px 24px;
    text-align: center;
}

.expensive-action-confirmation-modal .modal-header h3 {
    margin: 0;
    font-size: 1.3rem;
    font-weight: 600;
}

.expensive-action-confirmation-modal .modal-body {
    padding: 24px;
}

.action-summary {
    text-align: center;
}

.action-details h4 {
    margin: 0 0 12px 0;
    color: #1f2937;
    font-size: 1.2rem;
}

.action-details p {
    margin: 0 0 20px 0;
    color: #4b5563;
    font-size: 1rem;
}

.balance-breakdown {
    background: #f8fafc;
    border-radius: 12px;
    padding: 16px;
    margin: 20px 0;
    border: 1px solid #e5e7eb;
}

.balance-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
}

.balance-item:last-child {
    border-bottom: none;
}

.balance-item.total {
    border-top: 2px solid #d1d5db;
    padding-top: 12px;
    margin-top: 8px;
    font-weight: 600;
}

.balance-value {
    color: #3b82f6;
    font-weight: 600;
}

.cost-value {
    color: #dc2626;
    font-weight: 600;
}

.new-balance-value {
    color: #16a34a;
    font-weight: 600;
}

.new-balance-value.low-balance {
    color: #dc2626;
}

.low-balance-warning {
    background: #fef3c7;
    border: 1px solid #f59e0b;
    border-radius: 8px;
    padding: 12px;
    margin: 16px 0;
    text-align: left;
}

.low-balance-warning p {
    margin: 0;
    color: #92400e;
    font-size: 0.9rem;
}

.confirmation-question {
    margin: 20px 0;
}

.confirmation-question p {
    margin: 0;
    color: #1f2937;
    font-weight: 500;
    font-size: 1.1rem;
}

.expensive-action-confirmation-modal .modal-footer {
    padding: 20px 24px;
    background: #f8fafc;
    display: flex;
    gap: 12px;
    justify-content: center;
}

.expensive-action-confirmation-modal .primary-btn {
    background: #dc2626;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 160px;
}

.expensive-action-confirmation-modal .primary-btn:hover {
    background: #b91c1c;
    transform: translateY(-1px);
}

.expensive-action-confirmation-modal .secondary-btn {
    background: #6b7280;
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 120px;
}

.expensive-action-confirmation-modal .secondary-btn:hover {
    background: #4b5563;
    transform: translateY(-1px);
}

/* Mobile responsiveness for confirmation modal */
@media (max-width: 768px) {
    .expensive-action-confirmation-modal .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .expensive-action-confirmation-modal .modal-footer {
        flex-direction: column;
    }
    
    .expensive-action-confirmation-modal .primary-btn,
    .expensive-action-confirmation-modal .secondary-btn {
        width: 100%;
    }
}

/* Insufficient Credits Modal Styles */
.insufficient-credits-modal {
    background: white;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    margin: 20px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid #e1e5e9;
}

.insufficient-credits-modal h3 {
    margin: 0 0 16px 0;
    color: #dc2626;
    font-size: 1.2rem;
    font-weight: 600;
}

.insufficient-credits-modal p {
    margin: 8px 0;
    color: #374151;
    line-height: 1.5;
}

.insufficient-credits-modal .modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
    justify-content: flex-end;
}

.insufficient-credits-modal .btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.insufficient-credits-modal .btn-primary {
    background: #3b82f6;
    color: white;
}

.insufficient-credits-modal .btn-primary:hover {
    background: #2563eb;
    transform: translateY(-1px);
}

.insufficient-credits-modal .btn-secondary {
    background: #6b7280;
    color: white;
}

.insufficient-credits-modal .btn-secondary:hover {
    background: #4b5563;
    transform: translateY(-1px);
}
