/* ================ Assignment Generator CSS Styles ================ */

/* ================ Loading Animations ================ */
.loading-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

.loading-spinner-large {
    width: 24px;
    height: 24px;
    border-width: 3px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loading-pulse {
    display: inline-block;
    width: 12px;
    height: 12px;
    background-color: #0073aa;
    border-radius: 50%;
    margin-right: 8px;
    animation: pulse-scale 1.5s ease-in-out infinite;
    vertical-align: middle;
}

@keyframes pulse-scale {
    0% {
        transform: scale(0.8);
        opacity: 1;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.7;
    }
    100% {
        transform: scale(0.8);
        opacity: 1;
    }
}

.loading-dots {
    display: inline-block;
    margin-right: 8px;
    vertical-align: middle;
}

.loading-dots::after {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #0073aa;
    animation: dots 1.4s ease-in-out infinite both;
    margin-right: 2px;
}

.loading-dots::before {
    content: '';
    display: inline-block;
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background-color: #0073aa;
    animation: dots 1.4s ease-in-out infinite both;
    animation-delay: -0.16s;
    margin-right: 2px;
}

@keyframes dots {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ================ Processing Status Styles ================ */
.status-processing {
    color: #0073aa;
    font-weight: 500;
}

.status-success {
    color: #28a745;
    font-weight: 500;
}

.status-error {
    color: #dc3545;
    font-weight: 500;
}

.status-warning {
    color: #ffc107;
    font-weight: 500;
}

/* ================ Main Container ================ */
#back-to-tools {
    display: inline-flex;
    align-items: center;
    margin-bottom: 15px;
    text-decoration: none;
}

.ct-container-full {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh !important;
    width: 100%;
    padding-top: 0;
    padding-bottom: 0px;
}

#assignment-generator {
    width: 1000px;
    margin: 30px auto;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 10px;
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.1);
    font-family: Arial, sans-serif;
    background-color: #fff;
    min-height: calc(100vh - 15px); /* Reduced height by 15px */
}

#assignment-generator h3 {
    text-align: center;
    color: #333;
}

/* ================ Tab Container ================ */
.tab-container {
    margin-top: 20px;
    display: none;
}

.tab-navigation {
    display: flex;
    border-bottom: 2px solid #ddd;
    margin-bottom: 15px;
}

.tab-button {
    background: none;
    border: none;
    padding: 12px 20px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: #666;
    border-bottom: 2px solid transparent;
    transition: all 0.3s ease;
    position: relative;
}

.tab-button.active {
    color: #0073aa;
    border-bottom-color: #0073aa;
}

.tab-button:hover {
    color: #0073aa;
    background-color: #f8f9fa;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* ================ Assignment Output ================ */
#assignment-output {
    display: block;
    margin-top: 20px;
    padding: 10px;
    background-color: white !important;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    box-shadow: none;
}

#assignment-output pre {
    background-color: white !important;
    border: none;
    white-space: pre-wrap;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

#assignment-output h5, 
#assignment-output h3 {
    font-size: 15px;
    font-weight: bold;
    margin-top: -1px;
    margin-bottom: -5px;
}

#assignment-output ul {
    margin-top: -5px;
}

/* ================ Answer Sheet Output ================ */
#answer-sheet-output {
    display: block;
    padding: 15px;
    background-color: #f8f9fa;
    border: 1px solid #ddd;
    border-radius: 5px;
    width: 100%;
    font-family: 'Courier New', monospace;
}

#answer-sheet-output h3 {
    color: #0073aa;
    margin-bottom: 15px;
    text-align: center;
    font-size: 18px;
}

#answer-sheet-output .answer-item {
    margin-bottom: 10px;
    padding: 8px;
    background-color: white;
    border-radius: 4px;
    border-left: 3px solid #28a745;
}

#answer-sheet-output .question-number {
    font-weight: bold;
    color: #333;
}

#answer-sheet-output .correct-answer {
    color: #28a745;
    font-weight: 500;
    margin-left: 10px;
}

/* ================ Enhanced Button Styles with States ================ */
#generate-assignment {
    width: 100%;
    padding: 14px;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    cursor: pointer;
    transition: background-color 0.3s ease;
    background-color: #0073aa;
}

#generate-assignment:hover {
    background-color: #00567d;
}

/* Base styling for enhanced buttons */
#save-assignment, #save-answer-sheet, #export-to-google-form {
    padding: 12px 20px;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 500;
    min-width: 140px;
    height: 44px;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

/* Save button colors */
#save-assignment, #save-answer-sheet {
    background-color: #ff9800;
    width: 150px;
}

#save-assignment:hover:not(.button-loading):not(.button-success), 
#save-answer-sheet:hover:not(.button-loading):not(.button-success) {
    background-color: #f57c00;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(255, 152, 0, 0.3);
}

/* Export button colors */
#export-to-google-form {
    background-color: #4285f4;
    width: 200px;
}

#export-to-google-form:hover:not(.button-loading):not(.button-success) {
    background-color: #3367d6;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(66, 133, 244, 0.3);
}

/* Loading State */
.button-loading {
    background-color: #e0e0e0 !important;
    color: #757575 !important;
    cursor: not-allowed !important;
    transform: none !important;
    box-shadow: none !important;
}

/* Success State */
.button-success {
    background-color: #4caf50 !important;
    color: white !important;
    cursor: default !important;
}

/* Loading Spinner for buttons */
.button-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: button-spin 1s linear infinite;
    margin-right: 8px;
}

@keyframes button-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success Checkmark for buttons */
.button-checkmark {
    width: 16px;
    height: 16px;
    margin-right: 8px;
    opacity: 0;
    animation: button-checkmark-appear 0.3s ease-out forwards;
}

@keyframes button-checkmark-appear {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* Button Icons */
#save-assignment svg, #save-answer-sheet svg, #export-to-google-form svg {
    width: 16px;
    height: 16px;
    margin-right: 8px;
}

/* Other action buttons (copy, clear) */
#copy-assignment, #copy-answer-sheet {
    background-color: #4CAF50;
    padding: 10px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100px;
    justify-content: center;
}

#copy-assignment:hover, #copy-answer-sheet:hover {
    background-color: #388e3c;
}

#copy-assignment svg, #copy-answer-sheet svg {
    width: 18px;
    height: 18px;
    margin-right: 5px;
}

#clear-assignment {
    background-color: #f44336;
    padding: 10px;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    width: 100px;
    justify-content: center;
}

#clear-assignment:hover {
    background-color: #d32f2f;
}

#clear-assignment svg {
    width: 18px;
    height: 18px;
    margin-right: 5px;
    margin-bottom: 5px;
}

/* ================ Form Layout ================ */
.form-group {
    display: flex;
    justify-content: space-between;
    margin-bottom: 20px;
}

.form-group label {
    font-weight: bold;
    color: #555;
    margin-right: 10px;
    flex-basis: 40%;
    text-align: left;
}

.form-group input {
    flex-basis: 40%;
    padding: 10px;
    border: 1px solid #ccc;
    border-radius: 4px;
}

.form-row {
    display: flex;
    justify-content: space-between;
}

.form-column {
    width: 48%;
    display: flex;
    flex-direction: column;
}

/* ================ Form Matrix Container ================ */
.form-matrix-container {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-bottom: 20px;
}

.form-field {
    display: flex;
    flex-direction: column;
}

.form-field label {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
    color: #555;
}

.form-field select {
    width: 100%;
    padding: 7px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 14px;
    height: auto;
}

/* ================ File Upload Styles ================ */
.file-upload-container {
    margin-bottom: 20px;
    width: 100%;
    position: relative;
}

.file-upload-container label {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
    color: #555;
}

.file-upload-area {
    position: relative;
    width: 100%;
    height: auto;
    min-height: 60px;
    border: 2px dashed #0073aa;
    border-radius: 8px;
    background-color: #f9f9f9;
    padding: 10px;
    margin-bottom: 5px;
}

.file-upload-area input[type="file"] {
    width: 100%;
    opacity: 1;
    cursor: pointer;
    padding: 8px;
    position: relative;
    z-index: 2;
}

.file-upload-help {
    font-size: 10px;
    color: #666;
    margin-top: 5px;
    line-height: 1.4;
}

#files-preview-container {
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 15px;
    background-color: #fafafa;
    display: none;
    margin-top: 15px;
}

#files-preview-container h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

.file-item {
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px;
    margin: 5px 0;
    background-color: #f0f0f0;
    border-radius: 4px;
    border-left: 4px solid #0073aa;
}

.file-item:hover {
    background-color: #e8f4f8 !important;
}

.file-item button {
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 8px;
    cursor: pointer;
    font-size: 12px;
}

.file-item button:hover {
    background-color: #c82333 !important;
    transform: scale(1.05);
}

#files-analysis {
    display: none;
    margin-top: 10px;
}

#files-analysis details summary {
    font-weight: bold;
    margin-bottom: 5px;
    color: #155724;
    cursor: pointer;
}

#files-analysis details[open] summary {
    margin-bottom: 10px;
}

@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.6; }
    100% { opacity: 1; }
}

.processing {
    animation: pulse 1.5s ease-in-out infinite;
}

/* ================ Topic Input ================ */
#assignment-topic {
    width: 100%;
    padding: 10px;
    margin-bottom: 20px;
    border: 1px solid #ccc;
    border-radius: 4px;
    height: 100px;
}

#assignment-topic label {
    font-weight: bold;
    margin-bottom: 10px;
    display: block;
    color: #555;
}

/* ================ Question Types Section ================ */
.question-types-label {
    font-weight: bold;
    display: block;
    margin-bottom: 10px;
    color: #555;
}

#question-type-section {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    margin-bottom: 20px;
}

.question-type-group {
    flex: 1;
    min-width: 200px;
}

.question-type-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: normal;
}

.question-type-group input[type="checkbox"] {
    margin-right: 8px;
}

.question-type-group input[type="number"] {
    width: 100%;
    padding: 6px;
    margin-top: 4px;
    display: none;
    border: 1px solid #ccc;
    border-radius: 4px;
}

/* ================ Assignment Actions ================ */
#assignment-actions, #answer-sheet-actions {
    margin-top: 10px;
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    align-items: center;
    width: 100%;
}

/* ================ Responsive Design ================ */
@media screen and (max-width: 768px) {
    #assignment-generator {
        width: 100% !important;
        margin: 10px auto !important;
        padding: 15px !important;
    }
    
    #assignment-output {
        padding: 10px;
    }
    
    #assignment-actions, #answer-sheet-actions {
        display: flex;
        flex-direction: column;
    }
    
    #copy-assignment, #copy-answer-sheet,
    #clear-assignment {
        width: 100% !important;
        margin-bottom: 10px;
        justify-content: center;
    }
    
    #save-assignment, #save-answer-sheet, #export-to-google-form {
        width: 100% !important;
        margin-bottom: 10px;
    }
    
    .form-matrix-container {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .file-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .file-item > div:last-child {
        width: 100%;
        justify-content: space-between;
    }
    
    #files-preview-container {
        padding: 10px;
    }
    
    .tab-navigation {
        flex-direction: column;
    }
    
    .tab-button {
        width: 100%;
        text-align: left;
        border-bottom: 1px solid #ddd;
        border-right: none;
    }
    
    .tab-button.active {
        border-bottom: 1px solid #0073aa;
        border-right: none;
    }
}

@media screen and (max-width: 480px) {
    #assignment-generator {
        width: 100% !important;
        padding: 10px !important;
        margin: 5px auto !important;
    }
    
    #generate-assignment {
        font-size: 15px;
        padding: 12px;
    }
    
    #assignment-topic {
        height: 80px;
    }
    
    .form-matrix-container {
        gap: 10px;
    }
    
    .form-field label {
        font-size: 14px;
        margin-bottom: 8px;
    }
    
    .form-field select {
        padding: 10px;
        font-size: 14px; /* Prevents zoom on iOS */
    }
    
    #question-type-section {
        flex-direction: column;
        gap: 15px;
    }
    
    .question-type-group {
        min-width: auto;
        width: 100%;
    }
    
    .tab-button {
        padding: 10px 15px;
        font-size: 13px;
    }
}