/* Reset default margins and paddings */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Mobile-first approach - base styles for all devices */
body {
    font-family: 'Comic Neue', 'Comic Sans MS', 'Segoe UI Emoji', -apple-system, BlinkMacSystemFont, cursive, sans-serif;
    margin: 0;
    padding: 0;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

/* Fun background dots pattern */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: radial-gradient(rgba(255,255,255,0.15) 2px, transparent 2px);
    background-size: 25px 25px;
    pointer-events: none;
    z-index: 0;
}

/* Header Section Styling - COMPACT VERSION */
header {
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    padding: 8px 15px;
    border-bottom-left-radius: 20px;
    border-bottom-right-radius: 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.12);
    position: relative;
    z-index: 1;
}

.header-container {
    width: 100%;
    overflow: hidden;
    margin-bottom: 4px;
    text-align: center;
}

.header-image {
    max-width: 60px;
    height: auto;
    display: inline-block;
    margin: 0 auto;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 6px rgba(0,0,0,0.12);
    transition: transform 0.2s ease;
}

.header-image:active {
    transform: scale(0.95);
}

.school-badge {
    text-align: center;
    font-size: 14px;
    font-weight: bold;
    color: white;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.12);
    letter-spacing: 0.5px;
    margin-top: 2px;
    padding-bottom: 2px;
}

/* Tablet and desktop improvements */
@media (min-width: 768px) {
    header {
        padding: 10px 20px;
        border-bottom-left-radius: 25px;
        border-bottom-right-radius: 25px;
    }
    
    .header-image {
        max-width: 70px;
        border-width: 3px;
    }
    
    .school-badge {
        font-size: 16px;
    }
}

/* Container Styling - Mobile First */
.container {
    max-width: 500px;
    margin: 20px 15px;
    padding: 20px 15px;
    background: rgba(255, 255, 255, 0.95);
    border-radius: 30px;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.15);
    position: relative;
    z-index: 1;
    animation: floatIn 0.5s ease-out;
}

@media (min-width: 768px) {
    .container {
        margin: 30px auto;
        padding: 25px 30px;
        max-width: 550px;
    }
}

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

/* Fun Message */
.fun-message {
    text-align: center;
    font-size: 18px;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 20px;
    padding: 5px;
}

@media (min-width: 768px) {
    .fun-message {
        font-size: 22px;
        margin-bottom: 25px;
    }
}

/* Form Styling */
.form-group {
    margin-bottom: 20px;
}

label {
    display: block;
    margin-bottom: 10px;
    font-size: 1.1em;
    font-weight: bold;
    color: #4a5568;
}

@media (min-width: 768px) {
    label {
        font-size: 1.2em;
        margin-bottom: 12px;
    }
}

.file-input-wrapper {
    position: relative;
    display: block;
    width: 100%;
}

input[type="file"] {
    display: block;
    width: 100%;
    padding: 12px;
    font-size: 0.9em;
    border: 3px dashed #c3dafe;
    border-radius: 20px;
    background-color: #f7fafc;
    cursor: pointer;
    transition: all 0.3s ease;
    font-family: inherit;
    -webkit-appearance: none;
}

@media (min-width: 768px) {
    input[type="file"] {
        padding: 14px;
        font-size: 1em;
    }
}

input[type="file"]:active {
    transform: scale(0.98);
}

.file-input-icon {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
}

@media (min-width: 768px) {
    .file-input-icon {
        right: 15px;
        font-size: 22px;
    }
}

.file-hint {
    font-size: 0.8em;
    color: #718096;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

@media (min-width: 768px) {
    .file-hint {
        font-size: 0.85em;
    }
}

/* Upload Button */
.upload-btn {
    width: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 14px;
    font-size: 1.1em;
    font-weight: bold;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: inherit;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
    -webkit-appearance: none;
}

@media (min-width: 768px) {
    .upload-btn {
        padding: 15px;
        font-size: 1.2em;
        gap: 10px;
    }
}

.upload-btn:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.btn-icon {
    font-size: 1em;
}

@media (min-width: 768px) {
    .btn-icon {
        font-size: 1.1em;
    }
}

/* Gallery Button */
.button-image-container {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 15px;
    width: 100%;
}

.btn-gallery {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
    color: white;
    text-decoration: none;
    border-radius: 50px;
    font-size: 1em;
    font-weight: bold;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(240, 147, 251, 0.3);
    -webkit-tap-highlight-color: transparent;
}

@media (min-width: 768px) {
    .btn-gallery {
        padding: 12px 28px;
        font-size: 1.1em;
        gap: 10px;
    }
}

.btn-gallery:active {
    transform: translateY(1px);
    box-shadow: 0 2px 8px rgba(240, 147, 251, 0.4);
}

/* Fun Facts Section */
.fun-facts {
    margin-top: 25px;
    padding: 15px;
    background: linear-gradient(135deg, #ffeaa7 0%, #fdcb6e 100%);
    border-radius: 20px;
}

@media (min-width: 768px) {
    .fun-facts {
        margin-top: 30px;
        padding: 18px;
    }
}

.fact {
    padding: 5px;
    font-size: 0.85em;
    color: #2d3436;
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 1.4;
}

@media (min-width: 768px) {
    .fact {
        padding: 6px;
        font-size: 0.9em;
        gap: 10px;
    }
}

.fact::before {
    content: "⭐";
    font-size: 0.9em;
    flex-shrink: 0;
}

/* Footer */
footer {
    text-align: center;
    padding: 12px;
    color: white;
    font-size: 0.85em;
    font-weight: bold;
    text-shadow: 1px 1px 0 rgba(0,0,0,0.12);
    position: relative;
    z-index: 1;
}

@media (min-width: 768px) {
    footer {
        padding: 15px;
        font-size: 0.9em;
    }
}

/* Loading animation */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.upload-btn.loading {
    animation: pulse 1s infinite;
    pointer-events: none;
}

/* Custom file input styling for mobile */
input[type="file"]::file-selector-button {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 8px 12px;
    border: none;
    border-radius: 15px;
    cursor: pointer;
    font-family: inherit;
    margin-right: 8px;
    transition: all 0.3s ease;
    font-size: 0.85em;
}

@media (min-width: 768px) {
    input[type="file"]::file-selector-button {
        padding: 8px 14px;
        font-size: 0.9em;
        margin-right: 10px;
    }
}

input[type="file"]::file-selector-button:active {
    transform: scale(0.95);
}

/* Better touch targets for mobile */
button, 
.btn-gallery,
input[type="submit"],
input[type="file"]::file-selector-button {
    min-height: 44px;
}

/* Prevent zoom on input focus for iOS */
@media (max-width: 768px) {
    input[type="file"],
    button,
    .btn-gallery {
        font-size: 16px;
    }
}

/* Scrollbar styling */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 10px;
}

/* Safe area insets for modern phones */
@supports (padding: max(0px)) {
    .container {
        padding-left: max(15px, env(safe-area-inset-left));
        padding-right: max(15px, env(safe-area-inset-right));
    }
    
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Loading Overlay - Hourglass & Spinner */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

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

.loading-content {
    text-align: center;
    background: white;
    padding: 30px 25px;
    border-radius: 40px;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    max-width: 85%;
    animation: bounceIn 0.5s ease;
}

@keyframes bounceIn {
    0% {
        transform: scale(0.8);
        opacity: 0;
    }
    80% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

/* Hourglass Animation */
.hourglass {
    display: inline-block;
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto 20px;
}

.hourglass:before {
    content: "⏳";
    font-size: 80px;
    position: absolute;
    top: 0;
    left: 0;
    animation: hourglassSpin 2s infinite ease-in-out;
}

@keyframes hourglassSpin {
    0% {
        transform: rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: rotate(180deg);
        opacity: 0.6;
    }
    100% {
        transform: rotate(360deg);
        opacity: 1;
    }
}

/* Alternative: CSS-only hourglass */
.hourglass-alt {
    display: inline-block;
    width: 80px;
    height: 80px;
    position: relative;
    margin: 0 auto 20px;
}

.hourglass-alt::before {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-top: 60px solid #667eea;
    animation: hourglassDrop 2s infinite;
}

.hourglass-alt::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 0;
    border-left: 40px solid transparent;
    border-right: 40px solid transparent;
    border-bottom: 60px solid #764ba2;
    animation: hourglassRise 2s infinite;
}

@keyframes hourglassDrop {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateY(20px);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes hourglassRise {
    0% {
        transform: translateY(0);
        opacity: 1;
    }
    50% {
        transform: translateY(-20px);
        opacity: 0.5;
    }
    100% {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Spinner (fallback) */
.spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-right: 6px solid #f093fb;
    border-bottom: 6px solid #f5576c;
    border-left: 6px solid #764ba2;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 0.8s linear infinite;
}

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

.loading-text {
    font-size: 1.3em;
    font-weight: bold;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    background-clip: text;
    color: transparent;
    margin-bottom: 8px;
}

.loading-subtext {
    font-size: 0.9em;
    color: #718096;
    margin-bottom: 15px;
}

.progress-bar-container {
    width: 100%;
    height: 8px;
    background-color: #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    margin: 15px 0;
}

.progress-bar {
    width: 0%;
    height: 100%;
    background: linear-gradient(90deg, #667eea, #764ba2, #f093fb, #f5576c);
    background-size: 300% 100%;
    border-radius: 10px;
    transition: width 0.3s ease;
    animation: gradientShift 1.5s ease infinite;
}

@keyframes gradientShift {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.file-count {
    font-size: 0.85em;
    color: #4a5568;
    margin-top: 10px;
    font-style: italic;
}

/* Different loading states */
.loading-overlay.success .hourglass:before {
    content: "✅";
    animation: none;
    font-size: 80px;
}

.loading-overlay.error .hourglass:before {
    content: "❌";
    animation: none;
    font-size: 80px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .loading-content {
        padding: 25px 20px;
        max-width: 90%;
    }
    
    .hourglass:before {
        font-size: 60px;
    }
    
    .loading-text {
        font-size: 1.1em;
    }
    
    .loading-subtext {
        font-size: 0.8em;
    }
}