/* --- BASE & LAYOUT STYLES --- */
:root {
    --navbar-height: 60px;
    --sidebar-width: 280px;
}

*, *::before, *::after {
    box-sizing: border-box;
}

html,
body {
    height: 100%;
    overflow: hidden;
    font-family: 'Heebo', sans-serif;
    background-color: #f8f9fa;
    margin: 0;
    padding: 0;
    color: #2d3436;
    direction: rtl;
}

body {
    display: flex;
    flex-direction: column;
}

.problem-container {
    position: relative;
}

/* --- TOP NAVIGATION BAR --- */
.navbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--navbar-height);
    background-color: #ffffff;
    border-bottom: 1px solid #e9ecef;
    z-index: 1000;
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    /* --- Added for push transition --- */
    transition: transform 0.3s ease; 
}

/* --- REMOVED THIS BLOCK ---
.navbar.content-pushed {
    transform: translateX(calc(var(--sidebar-width) * -1));
}
*/


.navbar-title {
    font-family: 'SecularOne', sans-serif;
    font-size: 1.5rem;
    font-weight: 700;
    margin-right: 1rem;
    color: #ff6b35;
}

#menu-btn {
    background-color: transparent;
    color: #2d3436;
    border: none;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

#menu-btn:hover {
    background-color: #f1f3f5;
}

#menu-btn svg {
    width: 24px;
    height: 24px;
    stroke: #2d3436;
}


.main-container {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    position: relative;
    padding-top: var(--navbar-height); /* Push content below navbar */
    /* --- Added for push transition --- */
    transition: transform 0.3s ease;
}

/* --- Added for push effect --- */


#preview-container {
    flex-grow: 1;
    padding: 1.5rem;
    background-color: #f8f9fa;
    padding-bottom: 180px;
    padding-bottom: 180px;
    animation: fadeIn 0.4s ease;
    width: 100%;
    box-sizing: border-box; 
}

#preview-container.hidden {
    display: none;
}

#preview-pane {
    max-width: 960px;       /* Set a max width for the content. Adjust as needed. */
    margin: 0 auto;         /* This is key: it centers the pane horizontally. */
    background-color: white;/* The white paper background */
    padding: 2.5rem;          /* Internal spacing for the content. */
    border-radius: 8px;     /* Optional: soft rounded corners. */
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08); /* A subtle shadow to lift the page. */
    box-sizing: border-box;
}

/* --- WELCOME SCREEN STYLES --- */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    height: 100%;
    max-width: 700px;
    margin: 0 auto;
}

.welcome-logo {
    width: 80px;
    height: 80px;
    margin-bottom: 1.5rem;
    background-image: url('https://firebasestorage.googleapis.com/v0/b/worksheetgenai.firebasestorage.app/o/brand%2Flogo.png?alt=media&token=3f848fe3-d678-4f28-a325-8553f22c0cac');
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.welcome-title {
    font-size: 2rem;
    font-weight: 700;
    color: #2d3436;
    margin-bottom: 0.5rem;
}

.welcome-subtitle {
    font-size: 1.125rem;
    color: #636e72;
    margin-bottom: 2.5rem;
}

.welcome-instructions {
    list-style: none;
    padding: 0;
    margin: 0;
    text-align: right;
    max-width: 450px;
    font-size: 0.95rem;
}

.welcome-instructions li {
    background-color: #f8f9fa;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    border: 1px solid #e9ecef;
    display: flex;
    align-items: center;
}

.welcome-instructions strong {
    font-weight: 600;
    color: #ff6b35;
    margin-left: 0.75rem;
    min-width: 40px;
}


/* --- CHAT INPUT BAR --- */
#chat-input-container {
    position: sticky;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 1rem 1.5rem;
    z-index: 100;
    background: linear-gradient(180deg, rgba(248, 249, 250, 0) 0%, #f8f9fa 16%);
}

.chat-input-bar {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-width: 975px;
    margin: 0 auto;
    background-color: #ffffff;
    border: 1px solid #dee2e6;
    border-radius: 1.75rem; /* 28px */
    padding: 0.75rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
}

.chat-input-bar:focus-within {
    border-color: #ff6b35;
    box-shadow: 0 0 0 3px rgba(255, 107, 53, 0.2), 0 4px 12px rgba(0, 0, 0, 0.08);
}

.input-row {
    display: flex;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
}

#prompt-input {
    flex-grow: 1;
    font-family: 'Heebo', sans-serif;
    resize: none;
    border: none;
    background-color: transparent;
    padding: 0.5rem;
    font-size: 1rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
}

#prompt-input:focus {
    outline: none;
    box-shadow: none;
}


/* --- BUTTONS --- */
#generate-btn {
    background-color: #ff6b35;
    color: white;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: none;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

#generate-btn:disabled {
    background-color: #fd9a79;
    cursor: not-allowed;
}

#generate-btn:hover:not(:disabled) {
    background-color: #e05a2d;
    transform: translateY(-1px);
}

#action-buttons {
    display: none; /* Hidden by default, shown via JS */
    gap: 0.5rem;
    align-self: flex-start;
}

.action-button {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    background-color: #f1f3f5;
    color: #495057;
    padding: 0.5rem 1rem;
    border-radius: 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.action-button:hover {
    background-color: #e9ecef;
}

.action-button svg {
    width: 16px;
    height: 16px;
}

/* Edit button that appears on each problem in the preview */
.edit-problem-btn {
    background: #f1f3f5;
    color: #495057;
    border: none;
    padding: 6px 14px;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.8125rem;
    cursor: pointer;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    transition: all 0.2s ease;
    margin-left: auto; /* Pushes it to the end (left in RTL) */

    position: absolute;
    top: 15px;
    left: 15px;
}

.edit-problem-btn:hover {
    background: #e9ecef;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}


/* --- MODAL STYLES --- */
#edit-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    z-index: 1000;
    transition: opacity 0.3s ease;
}

#edit-modal.hidden {
    display: none;
}


/* --- MISC & PREVIEW PANE --- */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 2px solid #e9ecef;
}

.preview-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3436;
    margin: 0;
    letter-spacing: -0.5px;
}

/* This style is for the header of each individual problem */
.problem-header {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.loading-text {
    color: #ff6b35;
    font-size: 1.125rem;
    text-align: center;
    animation: pulse 1.5s ease-in-out infinite;
}

/* --- Error Details Dropdown Styling --- */
.error-details-dropdown {
    margin-top: 24px;
    width: 100%;
    max-width: 450px;
  }
  
  .error-details-dropdown summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #888;
    list-style: none; /* Removes the default arrow */
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
  }
  
  .error-details-dropdown summary:hover {
    background-color: #f7f7f7;
    color: #555;
  }
  
  /* Add a custom arrow for better styling */
  .error-details-dropdown summary::before {
    content: '▶';
    display: inline-block;
    margin-left: 8px;
    font-size: 10px;
    transition: transform 0.2s ease;
  }
  
  .error-details-dropdown[open] > summary::before {
    transform: rotate(90deg);
  }
  
  .error-details-content {
    margin-top: 12px;
    padding: 16px;
    background-color: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    text-align: left; /* Align technical details to the left */
    direction: ltr;
    font-family: monospace;
    font-size: 13px;
    color: #444;
    word-wrap: break-word;
  }
  
  .error-details-content p {
    margin: 0 0 8px 0;
  }

  /* --- Base Container for Errors & Prompts --- */
.error-message-container,
.upgrade-prompt-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    height: 100%;
    max-width: 600px;
    margin: 0 auto;
}

.error-icon,
.upgrade-icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}

.error-title,
.upgrade-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2d3436;
    margin-bottom: 0.5rem;
}

.error-text,
.upgrade-text {
    font-size: 1rem;
    color: #636e72;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

/* --- Specifics for Upgrade Prompt --- */
.upgrade-icon {
    color: #ff6b35; 
}

.upgrade-title {
    color: #e55a2b; 
}

.upgrade-button {
    display: inline-block;
    padding: 0.875rem 1.75rem;
    background: #ff6b35;
    color: white;
    border: none;
    border-radius: 6px;
    font-family: 'Heebo', sans-serif;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.upgrade-button:hover {
    background: #e55a2b;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.12);
}


/* --- Error Details Dropdown Styling --- */
.error-details-dropdown {
    margin-top: 24px;
    width: 100%;
    max-width: 450px;
  }
  
  .error-details-dropdown summary {
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #888;
    list-style: none; /* Removes the default arrow */
    padding: 8px 12px;
    border-radius: 6px;
    transition: background-color 0.2s ease;
  }
  
  .error-details-dropdown summary:hover {
    background-color: #f7f7f7;
    color: #555;
  }
  
  /* Add a custom arrow for better styling */
  .error-details-dropdown summary::before {
    content: '▶';
    display: inline-block;
    margin-left: 8px; /* margin-right in LTR */
    font-size: 10px;
    transition: transform 0.2s ease;
  }
  
  .error-details-dropdown[open] > summary::before {
    transform: rotate(90deg);
  }
  
  .error-details-content {
    margin-top: 12px;
    padding: 16px;
    background-color: #fafafa;
    border: 1px solid #eee;
    border-radius: 8px;
    text-align: left; /* Technical details are best in LTR */
    direction: ltr;
    font-family: monospace;
    font-size: 13px;
    color: #444;
    word-wrap: break-word;
  }
  
  .error-details-content p {
    margin: 0 0 8px 0;
  }
  
/* --- ANIMATIONS --- */
@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

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

@media (max-width: 768px) {
    
    #preview-container {
        /* Remove the container's padding to let the pane stretch */
        padding: 0;
        /* Re-apply the bottom padding so the chat bar doesn't cover content */
        padding-bottom: 180px;
        background-color: #ffffff;
    }

    #preview-pane {
        /* Remove the max-width limit */
        max-width: none;
        /* Remove the centering margin */
        margin: 0;
        /* Remove the "paper" look */
        box-shadow: none;
        border-radius: 0;
        /* Adjust internal padding for smaller screens */
        padding: 1.5rem;
    }

    #chat-input-container {
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        padding: 0rem 0.4rem;
        z-index: 100;
        background: none;
    }
}