/* Google Fonts */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Fredoka:wght@300;400;500;600;700&family=Nunito:wght@300;400;500;600;700;800;900&display=swap');

:root {
    --primary-color: #ff6b35;
    --primary-light: #ff8c69;
    --primary-dark: #e55a2b;
    --secondary-color: #4ecdc4;
    --secondary-light: #80e5de;
    --accent-color: #ffd93d;
    --accent-light: #ffe066;
    --success-color: #6bcf7f;
    --warning-color: #ffb347;
    --danger-color: #ff6b6b;
    --purple-fun: #a78bfa;
    --pink-fun: #fb7185;
    --bg-primary: #ffffff;
    --bg-secondary: #fef7ff;
    --bg-tertiary: #fef3c7;
    --text-primary: #2d3748;
    --text-secondary: #4a5568;
    --text-muted: #718096;
    --border-color: #e2e8f0;
    --shadow-sm: 0 2px 4px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 8px -2px rgb(0 0 0 / 0.15);
    --shadow-lg: 0 8px 25px -5px rgb(0 0 0 / 0.2);
    --radius-sm: 0.5rem;
    --radius-md: 1rem;
    --radius-lg: 1.5rem;
    --radius-xl: 2rem;
}

* {
    box-sizing: border-box;
}

body {
    background: linear-gradient(135deg, #ffd93d 0%, #ff6b35 50%, #4ecdc4 100%);
    font-family: 'Inter', 'Comic Sans MS', cursive, sans-serif;
    color: var(--text-primary);
    margin: 0;
    padding: 0;
    height: 100vh;
    overflow: hidden;
    font-size: 16px;
    line-height: 1.6;
    font-weight: 500;
}

.layout {
    display: flex;
    height: 100vh;
    gap: 1rem;
    padding: 1rem;
    align-items: stretch;
}

.sidebar {
    width: 320px;
    background: linear-gradient(145deg, #ffffff 0%, #fef7ff 100%);
    backdrop-filter: blur(15px);
    border: 3px solid var(--accent-color);
    border-radius: var(--radius-xl);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.sidebar::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 6px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.sidebar h2 {
    color: var(--primary-color);
    margin: 0 0 2rem 0;
    font-size: 1.8rem;
    font-weight: 700;
    text-align: center;
    padding-bottom: 1.5rem;
    border-bottom: 3px dashed var(--accent-color);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
    letter-spacing: 0.5px;
    line-height: 1.2;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 2rem 0;
    min-height: 0;
    gap: 0;
    position: relative;
}

.canvas-wrapper {
    position: relative;
    padding: 2rem;
    background: rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-xl);
    backdrop-filter: blur(10px);
}

.canvas-container {
    position: relative;
    display: inline-block;
}

#draw {
    background: var(--bg-primary);
    border: 4px solid var(--secondary-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
    cursor: crosshair;
    width: 768px;
    height: 512px;
    max-width: none;
    max-height: none;
    transition: all 0.3s ease;
}

#draw:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-lg);
}

.prompt-section {
    width: 100%;
    max-width: 768px;
    flex-shrink: 0;
    margin-bottom: 10px;
}

.prompt-row {
    display: flex;
    gap: 15px;
    align-items: flex-start;
    width: 100%;
}

.prompt-input {
    flex: 1;
    padding: 6px 12px;
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid #ffd6e0;
    border-radius: 10px;
    font-family: inherit;
    font-size: 0.95rem;
    color: #444;
    height: 38px;
    line-height: 1.2;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 214, 224, 0.3);
    box-sizing: border-box;
    vertical-align: middle;
    resize: none;
}

.canvas-controls {
    display: flex;
    gap: 1rem;
    align-items: center;
    flex-shrink: 0;
    width: 100%;
    max-width: 768px;
    background: var(--bg-primary);
    padding: 1rem;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-md);
}

/* Base button styles */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    padding: 1.5rem 2.5rem;
    font-size: 1.1rem;
    font-weight: 700;
    font-family: inherit;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.2s ease;
    text-decoration: none;
    min-height: 70px;
    position: relative;
    overflow: hidden;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn:hover:not(:disabled) {
    transform: translateY(-1px);
}

.btn:active:not(:disabled) {
    transform: translateY(0);
    transition: transform 0.1s ease;
}

/* Tool buttons */
.tool-btn {
    width: 100%;
    background: var(--bg-secondary);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: all 0.2s ease;
}

.tool-btn:hover {
    background: var(--bg-tertiary);
    border-color: var(--primary-light);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.tool-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgb(99 102 241 / 0.3);
}

.tool-btn img {
    filter: brightness(0) saturate(100%);
    transition: filter 0.2s ease;
}

.tool-btn.active img {
    filter: brightness(0) saturate(100%) invert(1);
}

.tool-btn span {
    font-weight: 500;
}

/* Action buttons */
.undo-btn {
    background: linear-gradient(135deg, var(--purple-fun) 0%, #c084fc 100%);
    color: white;
    border: 3px solid var(--purple-fun);
    margin-bottom: 1rem;
    width: 100%;
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

.clear-btn {
    background: linear-gradient(135deg, var(--danger-color) 0%, #ff8787 100%);
    color: white;
    border: 3px solid var(--danger-color);
    margin-bottom: 1rem;
    width: 100%;
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

.convert-btn {
    background: linear-gradient(135deg, var(--success-color) 0%, #4ade80 100%);
    color: white;
    border: 3px solid var(--success-color);
    margin-bottom: 1.5rem;
    width: 100%;
    box-shadow: 0 6px 20px rgba(107, 207, 127, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

.check-empty-btn {
    background: var(--text-secondary);
    color: white;
    border: 1px solid var(--text-secondary);
    margin-bottom: 1.25rem;
    box-shadow: 0 4px 12px rgb(100 116 139 / 0.3);
}

.check-empty-btn:hover {
    background: #475569;
    border-color: #475569;
}

.reset-btn {
    background: var(--secondary-color);
    color: white;
    border: 1px solid var(--secondary-color);
    box-shadow: 0 4px 12px rgb(236 72 153 / 0.3);
    min-width: 180px;
}

.prompt-input:focus {
    outline: none;
    border-color: #ff4081;
    box-shadow: 0 0 0 2px rgba(255, 64, 129, 0.2);
}

.prompt-input::placeholder {
    color: #aaa;
    font-style: italic;
}

.send-btn:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none !important;
}

.loading {
    opacity: 0.7;
    animation: pulse 1.5s ease-in-out infinite alternate;
}

@keyframes pulse {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 0.3;
    }
}

/* Sidebar controls styling */
.controls {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.tools {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    margin-bottom: 1.5rem;
    overflow-y: hidden;
}

.tools-section {
    border-bottom: 2px dashed var(--accent-color);
    padding-bottom: 1.5rem;
    margin-bottom: 1.5rem;
}

.tools-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

/* Status indicators */
.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 1rem;
}

.status-indicator.success {
    background: rgb(220 252 231);
    color: rgb(22 163 74);
    border: 1px solid rgb(187 247 208);
}

.status-indicator.warning {
    background: rgb(254 252 232);
    color: rgb(180 83 9);
    border: 1px solid rgb(253 230 138);
}

.status-indicator.error {
    background: rgb(254 242 242);
    color: rgb(220 38 38);
    border: 1px solid rgb(254 202 202);
}

/* Responsive design */
@media (max-width: 1200px) {
    .layout {
        padding: 1rem;
        gap: 1rem;
    }

    .sidebar {
        width: 300px;
        padding: 1.5rem;
    }

    #draw {
        width: 640px;
        height: 448px;
    }

    .canvas-controls {
        max-width: 640px;
    }
}

/* Mobile First - Small screens (phones) */
@media (max-width: 480px) {
    body {
        overflow: hidden;
        font-size: 16px;
        height: 100vh;
    }

    .layout {
        flex-direction: column;
        height: 100vh;
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .sidebar {
        display: none !important; /* Hide sidebar completely on mobile */
    }

    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 0;
        gap: 0.75rem;
        height: 100vh;
        box-sizing: border-box;
    }

    .canvas-wrapper {
        padding: 1rem;
        width: 100%;
        box-sizing: border-box;
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        background: rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-lg);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    #draw {
        width: 100%;
        max-width: calc(100vw - 2rem);
        height: 250px;
        margin: 0 auto;
        display: block;
    }

    /* Hide tablet controls */
    .tablet-controls {
        display: none !important;
    }

    /* Show mobile controls and header */
    .mobile-controls,
    .mobile-header {
        display: flex !important;
    }

    .mobile-controls {
        flex-direction: column;
        align-items: center;
        gap: 0.75rem;
        width: 100%;
        max-width: calc(100vw - 1rem);
        margin: 0 auto;
        flex: 0 0 auto;
        background: rgba(255, 255, 255, 0.1);
        padding: 1rem;
        border-radius: var(--radius-lg);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    .mobile-header {
        max-width: calc(100vw - 1rem);
        margin: 0 auto;
        padding: 0.75rem 1.25rem;
    }

    .mobile-header h2 {
        font-size: 1.3rem;
    }

    .mobile-controls .top-row {
        display: flex;
        gap: 0.75rem;
        width: 100%;
        max-width: 100%;
    }

    .mobile-controls .top-row .btn {
        flex: 1;
        min-height: 50px;
        font-size: 0.9rem;
        padding: 0.75rem;
        margin-bottom: 0;
    }

    .mobile-controls .top-row .btn span {
        display: none; /* Hide text on mobile for undo and clear buttons */
    }

    .mobile-controls .convert-btn {
        width: 100%;
        max-width: 100%;
        min-height: 55px;
        font-size: 1.1rem;
        padding: 1rem 1.5rem;
        margin-bottom: 0;
    }

    /* Smaller prediction text for mobile */
    #prediction-result {
        font-size: 1.3rem !important;
        padding: 0.3rem 0.6rem !important;
        bottom: 15px !important;
        max-width: calc(100vw - 4rem);
        word-wrap: break-word;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* Tablet Layout - Medium screens */
@media (min-width: 481px) and (max-width: 768px) {
    body {
        overflow: hidden;
        font-size: 16px;
        height: 100vh;
    }

    .layout {
        flex-direction: column;
        height: 100vh;
        padding: 0.75rem;
        gap: 0.75rem;
    }

    .sidebar {
        display: none !important; /* Hide sidebar completely on tablet */
    }

    .main-content {
        flex: 1;
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        padding: 0;
        gap: 1rem;
        height: 100vh;
        box-sizing: border-box;
    }

    .canvas-wrapper {
        padding: 1.5rem;
        width: 100%;
        box-sizing: border-box;
        flex: 0 0 auto;
        display: flex;
        justify-content: center;
        align-items: center;
        background: rgba(255, 255, 255, 0.15);
        border-radius: var(--radius-xl);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    #draw {
        width: 100%;
        max-width: 550px;
        height: 320px;
        margin: 0 auto;
        display: block;
    }

    /* Show tablet controls and header */
    .tablet-controls,
    .mobile-header {
        display: flex !important;
    }

    .tablet-controls {
        justify-content: center;
        gap: 0.75rem;
        width: 100%;
        max-width: 550px;
        margin: 0 auto;
        flex: 0 0 auto;
        background: rgba(255, 255, 255, 0.1);
        padding: 1rem 1.5rem;
        border-radius: var(--radius-xl);
        backdrop-filter: blur(10px);
        border: 2px solid rgba(255, 255, 255, 0.2);
    }

    .mobile-header {
        max-width: 550px;
        margin: 0 auto;
        padding: 1rem 1.5rem;
    }

    .mobile-header h2 {
        font-size: 1.6rem;
    }

    .tablet-controls .btn {
        flex: 1;
        max-width: 160px;
        min-height: 55px;
        font-size: 0.95rem;
        padding: 0.9rem 1.1rem;
        margin-bottom: 0;
    }

    /* Hide mobile controls */
    .mobile-controls {
        display: none !important;
    }

    /* Smaller prediction text for tablet */
    #prediction-result {
        font-size: 1.8rem !important;
        padding: 0.4rem 0.8rem !important;
        bottom: 20px !important;
        max-width: 450px;
    }
}

/* Desktop - hide responsive controls */
@media (min-width: 769px) {
    .tablet-controls,
    .mobile-controls,
    .mobile-header {
        display: none !important;
    }
}

/* Mobile header styling */
.mobile-header {
    width: 100%;
    background: linear-gradient(145deg, #ffffff 0%, #fef7ff 100%);
    backdrop-filter: blur(15px);
    border: 3px solid var(--accent-color);
    border-radius: var(--radius-lg);
    padding: 0.75rem 1.5rem;
    box-shadow: var(--shadow-md);
    position: relative;
    flex: 0 0 auto;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color), var(--accent-color));
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    z-index: 1;
}

.mobile-header h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.4rem;
    font-weight: 700;
    text-align: center;
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
    letter-spacing: 0.5px;
    line-height: 1.1;
    position: relative;
    z-index: 2;
}

/* Responsive button styling */
.tablet-controls .undo-btn,
.mobile-controls .undo-btn {
    background: linear-gradient(135deg, var(--purple-fun) 0%, #c084fc 100%);
    color: white;
    border: 3px solid var(--purple-fun);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 20px rgba(167, 139, 250, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

.tablet-controls .clear-btn,
.mobile-controls .clear-btn {
    background: linear-gradient(135deg, var(--danger-color) 0%, #ff8787 100%);
    color: white;
    border: 3px solid var(--danger-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 20px rgba(255, 107, 107, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

.tablet-controls .convert-btn,
.mobile-controls .convert-btn {
    background: linear-gradient(135deg, var(--success-color) 0%, #4ade80 100%);
    color: white;
    border: 3px solid var(--success-color);
    border-radius: var(--radius-lg);
    box-shadow: 0 6px 20px rgba(107, 207, 127, 0.4);
    text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.2);
    font-family: 'Fredoka', 'Nunito', 'Comic Sans MS', cursive, sans-serif;
}

#prediction-result {
    color: var(--primary-color);
    font-size: 2.5rem;
    font-weight: 700;
    pointer-events: none;
    text-align: center;
    letter-spacing: 1px;
    padding: 0.5rem 1rem;
    background: var(--bg-primary);
    border-radius: var(--radius-md);
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
    }
}