/* ========== AI TOOLS STYLING ========== */

/* AI Tool Descriptions */
.tool-description {
    font-size: 1.1rem;
    color: #6D8196;
    margin-bottom: 24px;
    padding: 16px;
    background: linear-gradient(135deg, rgba(109, 129, 150, 0.08) 0%, rgba(109, 129, 150, 0.12) 100%);
    border-left: 4px solid #6D8196;
    border-radius: 8px;
    line-height: 1.6;
}

/* AI Input Section */
.ai-tool-input-section {
    background: white;
    padding: 28px;
    border-radius: 16px;
    border: 2px solid #e2e8f0;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: 24px;
}

/* AI Labels */
.ai-label {
    display: block;
    font-weight: 600;
    color: #485566;
    margin-bottom: 8px;
    font-size: 1rem;
}

/* AI Inputs */
.ai-input,
.ai-textarea,
.ai-select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e2e8f0;
    border-radius: 10px;
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s;
    background: white;
    color: #2d3748;
}

.ai-input:focus,
.ai-textarea:focus,
.ai-select:focus {
    outline: none;
    border-color: #6D8196;
    box-shadow: 0 0 0 3px rgba(109, 129, 150, 0.1);
}

.ai-textarea {
    min-height: 120px;
    resize: vertical;
    line-height: 1.6;
}

/* AI Options Grid */
.ai-options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin: 24px 0;
}

.ai-option-group {
    display: flex;
    flex-direction: column;
}

/* AI Checkboxes */
.ai-checkbox-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ai-checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    background: #f7fafc;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.ai-checkbox-label:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.ai-checkbox-label input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
    accent-color: #6D8196;
}

.ai-checkbox-label input[type="checkbox"]:checked + span {
    font-weight: 600;
    color: #485566;
}

/* AI Generate Button */
.ai-generate-btn {
    width: 100%;
    padding: 16px 32px;
    background: linear-gradient(135deg, #6D8196 0%, #485566 100%);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 1.2rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    transition: all 0.3s;
    box-shadow: 0 4px 0 0 rgba(72, 85, 102, 0.8), 0 6px 16px rgba(0, 0, 0, 0.2);
    margin-top: 24px;
}

.ai-generate-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 0 0 rgba(72, 85, 102, 0.8), 0 10px 24px rgba(0, 0, 0, 0.25);
}

.ai-generate-btn:active {
    transform: translateY(2px);
    box-shadow: 0 2px 0 0 rgba(72, 85, 102, 0.8), 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ai-generate-btn .btn-icon {
    font-size: 1.5rem;
    animation: sparkle 2s infinite;
}

@keyframes sparkle {
    0%, 100% { transform: scale(1) rotate(0deg); }
    25% { transform: scale(1.2) rotate(-10deg); }
    75% { transform: scale(1.2) rotate(10deg); }
}

/* AI Output Section */
.ai-output-section {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.08) 0%, rgba(76, 175, 80, 0.12) 100%);
    padding: 28px;
    border-radius: 16px;
    border: 3px solid #4CAF50;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.15);
    margin-top: 24px;
}

.ai-output-section.hidden {
    display: none;
}

.ai-output-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 2px solid rgba(76, 175, 80, 0.3);
}

.ai-output-header h3 {
    color: #2e7d32;
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
}

.ai-output-actions {
    display: flex;
    gap: 10px;
}

.ai-action-btn {
    padding: 10px 18px;
    background: white;
    color: #2e7d32;
    border: 2px solid #4CAF50;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-action-btn:hover {
    background: #4CAF50;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.ai-action-btn:active {
    transform: translateY(0);
}

/* AI Output Content */
.ai-output-content {
    background: white;
    padding: 24px;
    border-radius: 12px;
    border: 2px solid rgba(76, 175, 80, 0.2);
    font-size: 1rem;
    line-height: 1.8;
    color: #2d3748;
    max-height: 600px;
    overflow-y: auto;
}

.ai-output-content h4 {
    color: #2e7d32;
    font-size: 1.3rem;
    margin-top: 24px;
    margin-bottom: 12px;
    padding-bottom: 8px;
    border-bottom: 2px solid rgba(76, 175, 80, 0.2);
}

.ai-output-content h4:first-child {
    margin-top: 0;
}

.ai-output-content p {
    margin: 12px 0;
}

.ai-output-content ol,
.ai-output-content ul {
    margin: 12px 0;
    padding-left: 28px;
}

.ai-output-content li {
    margin: 8px 0;
}

.ai-output-content strong {
    color: #2e7d32;
    font-weight: 600;
}

/* AI Loading Spinner with Lasso Video - Modal Overlay */
.ai-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: clamp(80px, 10vh, 120px) 20px clamp(40px, 5vh, 80px);
    gap: 24px;
    z-index: 9999;
    animation: fadeIn 0.3s ease-in-out;
    overflow-y: auto;
}

.ai-loading.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Loading content container with card style */
.ai-loading-container {
    background: white;
    padding: clamp(30px, 5vh, 60px) clamp(30px, 6vw, 80px);
    border-radius: clamp(16px, 2vw, 24px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: clamp(20px, 3vh, 32px);
    animation: scaleIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scaleIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Lasso barking video - responsive sizing */
.lasso-loading-video {
    width: clamp(220px, 25vw, 420px);
    height: clamp(220px, 25vw, 420px);
    object-fit: contain;
    border-radius: clamp(12px, 1.5vw, 20px);
    box-shadow: 0 8px 24px rgba(109, 129, 150, 0.2);
}

/* Rotating loading text */
.lasso-loading-text {
    font-size: clamp(1.1rem, 2.2vw, 1.6rem);
    font-weight: 700;
    color: #6D8196;
    text-align: center;
    animation: textPulse 2s ease-in-out infinite;
    max-width: clamp(320px, 85%, 550px);
    padding: 0 1rem;
}

@keyframes textPulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(0.98);
    }
}

/* Old spinner (kept as fallback) */
.ai-loading .spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #e2e8f0;
    border-top: 6px solid #6D8196;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.ai-loading p {
    font-size: 1.1rem;
    color: #6D8196;
    font-weight: 600;
}

/* ========== DARK MODE FOR AI TOOLS ========== */

body.dark-mode .tool-description {
    background: linear-gradient(135deg, rgba(109, 129, 150, 0.15) 0%, rgba(109, 129, 150, 0.2) 100%);
    color: var(--dm-text-secondary);
    border-left-color: var(--dm-blue);
}

body.dark-mode .ai-tool-input-section {
    background: var(--dm-surface-3);
    border-color: var(--dm-border);
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.3);
}

body.dark-mode .ai-label {
    color: var(--dm-text-primary);
}

body.dark-mode .ai-input,
body.dark-mode .ai-textarea,
body.dark-mode .ai-select {
    background: var(--dm-surface-2);
    color: var(--dm-text-primary);
    border-color: var(--dm-border);
}

body.dark-mode .ai-input:focus,
body.dark-mode .ai-textarea:focus,
body.dark-mode .ai-select:focus {
    border-color: var(--dm-blue);
    box-shadow: 0 0 0 3px rgba(96, 165, 250, 0.2);
}

body.dark-mode .ai-checkbox-label {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
    color: var(--dm-text-secondary);
}

body.dark-mode .ai-checkbox-label:hover {
    background: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
}

body.dark-mode .ai-checkbox-label input[type="checkbox"]:checked + span {
    color: var(--dm-text-primary);
}

body.dark-mode .ai-generate-btn {
    background: linear-gradient(135deg, var(--dm-blue) 0%, var(--dm-blue-hover) 100%);
    box-shadow: 0 4px 0 0 rgba(71, 85, 105, 0.8), 0 6px 16px rgba(15, 23, 42, 0.3);
}

body.dark-mode .ai-generate-btn:hover {
    box-shadow: 0 6px 0 0 rgba(71, 85, 105, 0.8), 0 10px 24px rgba(15, 23, 42, 0.4);
}

body.dark-mode .ai-generate-btn:active {
    box-shadow: 0 2px 0 0 rgba(71, 85, 105, 0.8), 0 4px 12px rgba(15, 23, 42, 0.3);
}

body.dark-mode .ai-output-section {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.12) 0%, rgba(76, 175, 80, 0.18) 100%);
    border-color: var(--dm-success);
}

body.dark-mode .ai-output-header {
    border-bottom-color: rgba(76, 175, 80, 0.3);
}

body.dark-mode .ai-output-header h3 {
    color: var(--dm-success);
}

body.dark-mode .ai-action-btn {
    background: var(--dm-surface-3);
    color: var(--dm-success);
    border-color: var(--dm-success);
}

body.dark-mode .ai-action-btn:hover {
    background: var(--dm-success);
    color: var(--dm-bg);
}

body.dark-mode .ai-output-content {
    background: var(--dm-surface-2);
    color: var(--dm-text-primary);
    border-color: rgba(76, 175, 80, 0.3);
}

body.dark-mode .ai-output-content h4 {
    color: var(--dm-success);
    border-bottom-color: rgba(76, 175, 80, 0.3);
}

body.dark-mode .ai-output-content strong {
    color: var(--dm-success);
}

body.dark-mode .ai-loading .spinner {
    border-color: var(--dm-surface-4);
    border-top-color: var(--dm-blue);
}

body.dark-mode .ai-loading p {
    color: var(--dm-text-secondary);
}

body.dark-mode .ai-loading {
    background: rgba(15, 23, 42, 0.85);
}

body.dark-mode .ai-loading-container {
    background: var(--dm-surface-3);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.7);
}

body.dark-mode .lasso-loading-video {
    box-shadow: 0 8px 24px rgba(96, 165, 250, 0.4);
}

body.dark-mode .lasso-loading-text {
    color: var(--dm-blue);
}

/* Responsive Design for Loading Animation */
@media (max-width: 1400px) {
    .lasso-loading-video {
        width: clamp(200px, 26vw, 360px);
        height: clamp(200px, 26vw, 360px);
    }

    .ai-loading-container {
        padding: clamp(25px, 4vh, 50px) clamp(25px, 5vw, 60px);
    }
}

@media (max-width: 1200px) {
    .lasso-loading-video {
        width: clamp(180px, 28vw, 320px);
        height: clamp(180px, 28vw, 320px);
    }

    .lasso-loading-text {
        font-size: clamp(1rem, 2.5vw, 1.4rem);
    }
}

@media (max-width: 1024px) {
    .lasso-loading-video {
        width: clamp(160px, 32vw, 280px);
        height: clamp(160px, 32vw, 280px);
    }

    .ai-loading-container {
        padding: clamp(20px, 3vh, 40px) clamp(20px, 4vw, 50px);
        gap: clamp(16px, 2.5vh, 24px);
    }
}

/* Responsive Design for AI Tools */
@media (max-width: 768px) {
    /* Loading animation mobile adjustments */
    .lasso-loading-video {
        width: clamp(140px, 40vw, 220px);
        height: clamp(140px, 40vw, 220px);
    }

    .lasso-loading-text {
        font-size: clamp(0.95rem, 3.5vw, 1.25rem);
        max-width: clamp(260px, 90%, 400px);
    }

    .ai-loading-container {
        padding: clamp(20px, 4vh, 35px) clamp(15px, 3vw, 30px);
    }

    .ai-loading {
        padding: clamp(60px, 8vh, 100px) 15px clamp(30px, 4vh, 60px);
    }

    /* AI Tools grid and layout */
    .ai-options-grid {
        grid-template-columns: 1fr;
    }

    .ai-output-header {
        flex-direction: column;
        gap: 16px;
        align-items: flex-start;
    }

    .ai-output-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .ai-action-btn {
        flex: 1;
        min-width: 120px;
    }
}

/* Extra small devices */
@media (max-width: 480px) {
    .lasso-loading-video {
        width: clamp(110px, 45vw, 180px);
        height: clamp(110px, 45vw, 180px);
    }

    .lasso-loading-text {
        font-size: clamp(0.85rem, 4vw, 1.1rem);
        padding: 0 0.75rem;
    }

    .ai-loading-container {
        padding: clamp(15px, 3vh, 25px) clamp(12px, 2vw, 20px);
        gap: clamp(12px, 2vh, 18px);
    }
}

/* ========== FILE UPLOAD STYLING ========== */

/* Tab Buttons */
.input-tab-btn {
    padding: 12px 24px;
    background: white;
    color: #6D8196;
    border: 2px solid #e2e8f0;
    border-bottom: none;
    border-radius: 8px 8px 0 0;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.input-tab-btn:hover {
    background: #f7fafc;
}

.input-tab-btn.active {
    background: #6D8196;
    color: white;
    border-color: #6D8196;
}

/* File Upload Area */
.file-upload-area {
    width: 100%;
    min-height: 180px;
    border: 3px dashed #cbd5e0;
    border-radius: 12px;
    background: #f7fafc;
    padding: 32px;
    text-align: center;
    position: relative;
    transition: all 0.3s;
    cursor: pointer;
}

.file-upload-area:hover {
    border-color: #6D8196;
    background: #edf2f7;
}

.file-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}

.file-upload-info {
    pointer-events: none;
}

.selected-file-name {
    margin-top: 16px;
    padding: 12px 16px;
    background: #dbeafe;
    color: #1e40af;
    border-radius: 8px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.selected-file-name.hidden {
    display: none;
}

/* Dark Mode for File Upload */
body.dark-mode .input-tab-btn {
    background: var(--dm-surface-3);
    color: var(--dm-text-secondary);
    border-color: var(--dm-border);
}

body.dark-mode .input-tab-btn:hover {
    background: var(--dm-surface-4);
}

body.dark-mode .input-tab-btn.active {
    background: var(--dm-blue);
    color: var(--dm-text-primary);
    border-color: var(--dm-blue);
}

body.dark-mode .file-upload-area {
    background: var(--dm-surface-2);
    border-color: var(--dm-border);
}

body.dark-mode .file-upload-area:hover {
    border-color: var(--dm-blue);
    background: var(--dm-surface-3);
}

body.dark-mode .selected-file-name {
    background: rgba(96, 165, 250, 0.2);
    color: var(--dm-blue);
}

/* ========== PRINT STYLES FOR WORKSHEETS ========== */

@media print {
    /* Hide UI elements when printing */
    .ai-tool-input-section,
    .ai-output-header,
    .tool-description,
    .ai-output-section {
        border: none !important;
        box-shadow: none !important;
        background: white !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Hide action buttons */
    .ai-output-actions,
    .ai-action-btn {
        display: none !important;
    }

    /* Format the output content for printing */
    .ai-output-content {
        max-height: none !important;
        overflow: visible !important;
        padding: 0 !important;
        border: none !important;
        background: white !important;
        color: #000 !important;
        font-size: 12pt !important;
        line-height: 1.6 !important;
    }

    /* Headings */
    .ai-output-content h4 {
        color: #000 !important;
        font-size: 14pt !important;
        font-weight: bold !important;
        margin-top: 20pt !important;
        margin-bottom: 10pt !important;
        padding-bottom: 4pt !important;
        border-bottom: 1px solid #ccc !important;
        page-break-after: avoid !important;
    }

    .ai-output-content h4:first-child {
        margin-top: 0 !important;
    }

    /* Paragraphs */
    .ai-output-content p {
        margin: 8pt 0 !important;
        color: #000 !important;
    }

    /* Lists - Add space for answers */
    .ai-output-content ol,
    .ai-output-content ul {
        margin: 12pt 0 !important;
        padding-left: 24pt !important;
        list-style-position: outside !important;
    }

    /* List items - Add answer lines based on question type */
    .ai-output-content li {
        margin: 0 0 18pt 0 !important;
        padding-bottom: 0 !important;
        page-break-inside: avoid !important;
        color: #000 !important;
        position: relative !important;
    }

    /* Add answer lines after questions */
    .ai-output-content ol > li::after {
        content: "" !important;
        display: block !important;
        margin-top: 6pt !important;
        border-bottom: 1px solid #999 !important;
        width: 100% !important;
        height: 24pt !important;
    }

    /* Short answer questions - more space */
    .ai-output-content li:has(br)::after,
    .ai-output-content li em::after {
        height: 48pt !important;
    }

    /* Multiple choice - less space after options */
    .ai-output-content li:has(br) {
        margin-bottom: 12pt !important;
    }

    /* Strong/bold text */
    .ai-output-content strong {
        font-weight: bold !important;
        color: #000 !important;
    }

    /* Divs (like reading passages) */
    .ai-output-content div {
        padding: 12pt !important;
        border: 1px solid #ccc !important;
        border-radius: 4pt !important;
        margin: 12pt 0 !important;
        background: #f9f9f9 !important;
        page-break-inside: avoid !important;
    }

    /* Exit ticket specific - dashed border boxes */
    .ai-output-content div[style*="dashed"] {
        border: 2px dashed #666 !important;
        padding: 16pt !important;
        margin: 16pt 0 !important;
        background: white !important;
    }

    /* Name and Date fields */
    .ai-output-content p strong:first-child {
        display: inline-block !important;
        margin-right: 8pt !important;
    }

    /* Ensure page breaks work properly */
    .ai-output-content h4 {
        page-break-after: avoid !important;
    }

    .ai-output-content ol,
    .ai-output-content ul,
    .ai-output-content div {
        page-break-inside: avoid !important;
    }

    /* Remove hyperlinks styling */
    .ai-output-content a {
        color: #000 !important;
        text-decoration: none !important;
    }

    /* Checkboxes for multiple choice or exit tickets */
    .ai-output-content p:has(☐) {
        margin: 6pt 0 !important;
    }

    /* Glossary terms */
    .ai-output-content ul li {
        margin-bottom: 8pt !important;
    }

    .ai-output-content ul li::after {
        content: none !important;
    }

    /* Blank lines for fill-in-the-blank */
    .ai-output-content li:has(u)::after,
    .ai-output-content p:has(u)::after {
        height: 18pt !important;
    }

    /* Answer key items (should be hidden or minimal) */
    .ai-output-content em {
        font-size: 10pt !important;
        color: #666 !important;
    }

    /* Timestamps */
    .ai-output-content li:has(br) br + text {
        font-size: 10pt !important;
        color: #666 !important;
    }

    /* True/False questions - compact spacing */
    .ai-output-content li:contains("True"),
    .ai-output-content li:contains("False") {
        margin-bottom: 12pt !important;
    }

    .ai-output-content li:contains("True")::after,
    .ai-output-content li:contains("False")::after {
        height: 0 !important;
        border: none !important;
    }

    /* Vocab glossary - no answer lines */
    .ai-output-content h4:contains("Vocabulary")::after,
    .ai-output-content h4:contains("Glossary")::after {
        content: "" !important;
    }

    /* Standards section - compact */
    .ai-output-content h4:contains("Standards")::after {
        content: "" !important;
    }

    /* Add header info at top of page */
    .ai-output-content::before {
        content: "Name: ________________________     Date: ____________     Period: ____" !important;
        display: block !important;
        margin-bottom: 24pt !important;
        padding-bottom: 12pt !important;
        border-bottom: 2px solid #000 !important;
        font-size: 12pt !important;
        font-weight: normal !important;
    }

    /* Remove the header if there's already a name/date field */
    .ai-output-content:has(p:contains("Name:"))::before {
        display: none !important;
    }

    /* Ensure clean page margins */
    @page {
        margin: 0.75in !important;
        size: letter !important;
    }

    /* Force black and white printing */
    * {
        -webkit-print-color-adjust: exact !important;
        print-color-adjust: exact !important;
    }

    /* But keep backgrounds white for readability */
    .ai-output-content * {
        background: white !important;
    }

    .ai-output-content div[style*="background"] {
        background: #f9f9f9 !important;
    }
}
