/* ========================================
   Assignment Cover Page Generator
   Main Stylesheet
   ======================================== */

/* CSS Variables */
:root {
    --primary-color: #E86C31;
    --primary-dark: #c75a28;
    --primary-light: #ff8a50;
    --secondary-color: #1e293b;
    --accent-color: #3b82f6;
    
    --bg-gradient-start: #0f172a;
    --bg-gradient-end: #1e293b;
    --surface-color: rgba(255, 255, 255, 0.05);
    --surface-hover: rgba(255, 255, 255, 0.08);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    
    --font-primary: 'Outfit', sans-serif;
    --font-secondary: 'Poppins', sans-serif;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.15);
    --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 40px rgba(232, 108, 49, 0.2);
    
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    --transition-slow: 400ms ease;
}

/* Reset & Base Styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-primary);
    background: linear-gradient(135deg, var(--bg-gradient-start) 0%, var(--bg-gradient-end) 100%);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* App Container */
.app-container {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========================================
   Header Styles
   ======================================== */
.app-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(180deg, rgba(232, 108, 49, 0.1) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
}

.header-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.logo-icon {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.logo-icon svg {
    width: 28px;
    height: 28px;
    color: white;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
}

.logo h1 {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.5px;
}

.logo h1 span {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
}

/* ========================================
   Main Content Layout
   ======================================== */
.main-content {
    flex: 1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    padding: 2rem;
    max-width: 1600px;
    margin: 0 auto;
    width: 100%;
}

/* ========================================
   Panel Styles
   ======================================== */
.form-panel,
.preview-panel {
    background: var(--surface-color);
    backdrop-filter: blur(20px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.panel-header {
    padding: 1.5rem 2rem;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.03) 0%, transparent 100%);
    border-bottom: 1px solid var(--border-color);
}

.panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.panel-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

/* ========================================
   Form Styles
   ======================================== */
.cover-form {
    padding: 1.5rem 2rem 2rem;
    overflow-y: auto;
    flex: 1;
}

.form-section {
    margin-bottom: 2rem;
    padding-bottom: 2rem;
    border-bottom: 1px solid var(--border-color);
}

.form-section:last-of-type {
    border-bottom: none;
    margin-bottom: 1.5rem;
    padding-bottom: 0;
}

.section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 1.25rem;
    color: var(--text-primary);
}

.section-icon {
    font-size: 1.125rem;
}

.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.required {
    color: var(--error-color);
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 1rem;
    align-items: end;
}

.form-row .form-group {
    margin-bottom: 0;
}

/* Input Styles */
input[type="text"],
input[type="email"],
textarea {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: all var(--transition-fast);
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    background: rgba(232, 108, 49, 0.05);
    box-shadow: 0 0 0 3px rgba(232, 108, 49, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: var(--text-muted);
}

textarea {
    resize: vertical;
    min-height: 60px;
}

/* Student Entry Styles */
.student-entry {
    margin-bottom: 0.75rem;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.btn-remove-student {
    width: 40px;
    height: 40px;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: var(--radius-md);
    color: var(--error-color);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
    flex-shrink: 0;
}

.btn-remove-student:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error-color);
}

.btn-remove-student:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.btn-remove-student svg {
    width: 18px;
    height: 18px;
}

.btn-add-student {
    width: 100%;
    padding: 0.75rem 1rem;
    background: rgba(232, 108, 49, 0.1);
    border: 1px dashed rgba(232, 108, 49, 0.3);
    border-radius: var(--radius-md);
    color: var(--primary-color);
    font-family: var(--font-primary);
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.btn-add-student:hover {
    background: rgba(232, 108, 49, 0.15);
    border-color: rgba(232, 108, 49, 0.5);
}

.btn-add-student svg {
    width: 18px;
    height: 18px;
}

/* File Upload Styles */
.file-upload-wrapper {
    position: relative;
}

.file-input {
    position: absolute;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
    z-index: 2;
}

.file-upload-area {
    padding: 2rem;
    background: rgba(255, 255, 255, 0.02);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-md);
    text-align: center;
    transition: all var(--transition-fast);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(232, 108, 49, 0.05);
}

.upload-icon {
    width: 48px;
    height: 48px;
    margin: 0 auto 0.75rem;
    color: var(--text-muted);
}

.upload-icon svg {
    width: 100%;
    height: 100%;
}

.file-upload-area p {
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

.file-types {
    color: var(--text-muted);
    font-size: 0.75rem;
}

.logo-preview-container {
    position: relative;
    display: inline-block;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: var(--radius-md);
    border: 1px solid var(--border-color);
}

.logo-preview-container img {
    max-width: 150px;
    max-height: 100px;
    object-fit: contain;
}

.btn-remove-logo {
    position: absolute;
    top: -8px;
    right: -8px;
    width: 28px;
    height: 28px;
    background: var(--error-color);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition-fast);
}

.btn-remove-logo:hover {
    transform: scale(1.1);
}

.btn-remove-logo svg {
    width: 14px;
    height: 14px;
}

/* Color Picker Styles */
.color-picker-wrapper {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

input[type="color"] {
    width: 48px;
    height: 48px;
    padding: 0;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    overflow: hidden;
    flex-shrink: 0;
}

input[type="color"]::-webkit-color-swatch-wrapper {
    padding: 0;
}

input[type="color"]::-webkit-color-swatch {
    border: none;
    border-radius: var(--radius-md);
}

#themeColorText {
    width: 100px;
    flex-shrink: 0;
}

.color-presets {
    display: flex;
    gap: 0.5rem;
}

.color-preset {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: all var(--transition-fast);
}

.color-preset:hover {
    transform: scale(1.15);
}

.color-preset:nth-child(1) { background: #E86C31; }
.color-preset:nth-child(2) { background: #1E40AF; }
.color-preset:nth-child(3) { background: #047857; }
.color-preset:nth-child(4) { background: #7C3AED; }
.color-preset:nth-child(5) { background: #DC2626; }

/* ========================================
   Button Styles
   ======================================== */
.form-actions {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.btn {
    flex: 1;
    min-width: 150px;
    padding: 1rem 1.5rem;
    border: none;
    border-radius: var(--radius-md);
    font-family: var(--font-primary);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    transition: all var(--transition-fast);
}

.btn svg {
    width: 20px;
    height: 20px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color), var(--primary-dark));
    color: white;
    box-shadow: var(--shadow-md), var(--shadow-glow);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg), 0 0 60px rgba(232, 108, 49, 0.3);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

/* ========================================
   Preview Panel Styles
   ======================================== */
.preview-wrapper {
    flex: 1;
    padding: 1.5rem;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    overflow: auto;
    background: radial-gradient(ellipse at center, rgba(232, 108, 49, 0.05) 0%, transparent 70%);
}

.preview-container {
    width: 100%;
    max-width: 500px;
    box-shadow: var(--shadow-lg);
    border-radius: var(--radius-sm);
    overflow: hidden;
}

/* ========================================
   Footer Styles
   ======================================== */
.app-footer {
    padding: 1.5rem 2rem;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.875rem;
    border-top: 1px solid var(--border-color);
}

/* ========================================
   Loading Overlay
   ======================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.9);
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
}

.loading-overlay.active {
    opacity: 1;
    visibility: visible;
}

.loading-spinner {
    text-align: center;
}

.spinner {
    width: 60px;
    height: 60px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    color: var(--text-secondary);
    font-size: 1rem;
}

/* ========================================
   Responsive Styles
   ======================================== */
@media (max-width: 1200px) {
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .preview-panel {
        order: -1;
        max-height: 60vh;
    }
    
    .preview-wrapper {
        padding: 1rem;
    }
    
    .preview-container {
        max-width: 400px;
    }
}

@media (max-width: 768px) {
    .app-header {
        padding: 1rem;
    }
    
    .header-content {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .logo {
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .logo-icon {
        width: 40px;
        height: 40px;
    }
    
    .logo-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .tagline {
        font-size: 0.85rem;
    }
    
    .main-content {
        padding: 0.75rem;
        gap: 0.75rem;
    }
    
    .form-panel,
    .preview-panel {
        border-radius: var(--radius-lg);
    }
    
    .preview-panel {
        max-height: 50vh;
        min-height: 280px;
    }
    
    .panel-header {
        padding: 1rem 1.25rem;
    }
    
    .panel-header h2 {
        font-size: 1.1rem;
    }
    
    .panel-header p {
        font-size: 0.8rem;
    }
    
    .cover-form {
        padding: 1rem 1.25rem 1.25rem;
    }
    
    .form-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }
    
    .section-title {
        font-size: 0.95rem;
        margin-bottom: 1rem;
    }
    
    .form-group {
        margin-bottom: 0.875rem;
    }
    
    .form-group label {
        font-size: 0.8rem;
    }
    
    .form-row {
        grid-template-columns: 1fr;
        gap: 0.875rem;
    }
    
    input[type="text"],
    input[type="email"],
    textarea {
        padding: 0.875rem 1rem;
        font-size: 16px; /* Prevents iOS zoom on focus */
        border-radius: var(--radius-sm);
    }
    
    .btn-remove-student {
        width: 100%;
        height: 44px; /* Better touch target */
        padding: 0.5rem;
        margin-top: 0.5rem;
        gap: 0.5rem;
    }
    
    .btn-remove-student::before {
        content: 'Remove';
        font-size: 0.85rem;
        font-weight: 500;
    }
    
    .btn-add-student {
        padding: 0.875rem 1rem;
        min-height: 48px; /* Better touch target */
    }
    
    .file-upload-area {
        padding: 1.5rem 1rem;
    }
    
    .upload-icon {
        width: 40px;
        height: 40px;
    }
    
    .color-picker-wrapper {
        flex-direction: column;
        align-items: stretch;
        gap: 0.75rem;
    }
    
    .color-picker-wrapper > input[type="color"] {
        width: 100%;
        height: 48px;
    }
    
    #themeColorText {
        width: 100%;
    }
    
    .color-presets {
        justify-content: center;
        flex-wrap: wrap;
        gap: 0.75rem;
    }
    
    .color-preset {
        width: 36px;
        height: 36px;
    }
    
    .form-actions {
        flex-direction: column;
        gap: 0.75rem;
    }
    
    .btn {
        min-width: 100%;
        padding: 1rem 1.25rem;
        min-height: 52px; /* Better touch target */
        font-size: 0.95rem;
    }
    
    .preview-wrapper {
        padding: 0.75rem;
    }
    
    .preview-container {
        max-width: 100%;
    }
    
    .app-footer {
        padding: 1rem;
        font-size: 0.8rem;
    }
    
    /* Loading overlay adjustments */
    .spinner {
        width: 50px;
        height: 50px;
    }
    
    .loading-spinner p {
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    html {
        font-size: 14px;
    }
    
    .logo h1 {
        font-size: 1.5rem;
    }
    
    .main-content {
        padding: 0.5rem;
        gap: 0.5rem;
    }
    
    .preview-panel {
        max-height: 45vh;
        min-height: 250px;
    }
    
    .panel-header {
        padding: 0.875rem 1rem;
    }
    
    .cover-form {
        padding: 0.875rem 1rem 1rem;
    }
    
    .form-section {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }
    
    .section-icon {
        font-size: 1rem;
    }
    
    .file-upload-area {
        padding: 1.25rem 0.75rem;
    }
    
    .file-upload-area p {
        font-size: 0.8rem;
    }
    
    .file-types {
        font-size: 0.7rem;
    }
    
    .logo-preview-container img {
        max-width: 120px;
        max-height: 80px;
    }
}

/* Extra small devices (320px) */
@media (max-width: 360px) {
    html {
        font-size: 13px;
    }
    
    .app-header {
        padding: 0.75rem;
    }
    
    .logo-icon {
        width: 36px;
        height: 36px;
    }
    
    .logo h1 {
        font-size: 1.35rem;
    }
    
    .tagline {
        font-size: 0.75rem;
    }
    
    .panel-header h2 {
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 0.875rem;
    }
    
    .preview-panel {
        min-height: 220px;
    }
    
    .btn {
        padding: 0.875rem 1rem;
        font-size: 0.875rem;
    }
}

/* ========================================
   Animations & Polish
   ======================================== */

/* Keyframes */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes float {
    0% { transform: translateY(0px); }
    50% { transform: translateY(-5px); }
    100% { transform: translateY(0px); }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Entry Animations */
.app-header {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) backwards;
}

.form-panel {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.1s backwards;
}

.preview-panel {
    animation: fadeInUp 0.8s cubic-bezier(0.16, 1, 0.3, 1) 0.2s backwards;
}

/* Staggered Form Sections */
.form-section {
    animation: fadeInUp 0.6s ease-out backwards;
}

.form-section:nth-child(1) { animation-delay: 0.2s; }
.form-section:nth-child(2) { animation-delay: 0.3s; }
.form-section:nth-child(3) { animation-delay: 0.4s; }
.form-section:nth-child(4) { animation-delay: 0.5s; }

/* Enhanced Interactions */
.form-group:focus-within label {
    color: var(--primary-color);
    transition: color 0.3s ease;
}

.btn-primary {
    position: relative;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.btn-primary:hover {
    transform: translateY(-2px) scale(1.02);
    box-shadow: 0 10px 20px rgba(232, 108, 49, 0.2);
}

.btn-primary::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 200%;
    height: 100%;
    background: linear-gradient(115deg, transparent, rgba(255,255,255,0.2), transparent);
    transform: translateX(-100%);
    transition: transform 0.6s;
}

.btn-primary:hover::after {
    transform: translateX(50%);
}

.preview-container {
    animation: scaleIn 1s cubic-bezier(0.16, 1, 0.3, 1) 0.3s backwards;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1), box-shadow 0.4s ease;
}

.preview-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

/* File Upload Animation */
.file-upload-area {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.file-upload-area:hover, 
.file-upload-area.drag-active {
    transform: scale(1.02);
    border-color: var(--primary-color);
    background: rgba(232, 108, 49, 0.08);
    box-shadow: 0 0 20px rgba(232, 108, 49, 0.1);
}

/* Scrollbar Styles */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    transition: background 0.3s;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.4);
}
