/* Reset e Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    padding-bottom: 80px;
}

/* Header */
header {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.1);
    position: sticky;
    top: 0;
    z-index: 100;
}

header h1 {
    font-size: 1.5rem;
    color: #2196F3;
    font-weight: 600;
}

.header-controls {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    background: #2196F3;
    color: white;
    border: none;
    padding: 0.5rem;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    background: #1976D2;
    transform: scale(1.1);
}

/* Main Content */
main {
    padding: 1rem;
    max-width: 1200px;
    margin: 0 auto;
}

.section {
    display: none;
    animation: fadeIn 0.3s ease-in;
}

.section.active {
    display: block;
}

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

/* Canvas Container */
.canvas-container {
    position: relative;
    background: linear-gradient(145deg, #f8f9fa, #e9ecef);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    margin-bottom: 1rem;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 400px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    padding: 20px;
}

.canvas-container::before {
    content: '';
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    bottom: 10px;
    border: 2px dashed rgba(33, 150, 243, 0.3);
    border-radius: 12px;
    pointer-events: none;
    z-index: 1;
}

#drawingCanvas {
    display: block;
    width: 100%;
    height: auto;
    max-height: 60vh;
    cursor: crosshair;
    touch-action: none;
    position: relative;
    z-index: 2;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    border-radius: 8px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

#drawingCanvas.drawing-active {
    box-shadow: 0 8px 32px rgba(33, 150, 243, 0.3);
    transform: scale(1.01);
}

.canvas-overlay {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    pointer-events: none;
    z-index: 10;
}

.recognition-result, .shape-result {
    background: rgba(33, 150, 243, 0.95);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 25px;
    margin-bottom: 0.5rem;
    font-size: 1rem;
    font-weight: 500;
    display: none;
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.3);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    word-wrap: break-word;
}

.recognition-result.show, .shape-result.show {
    display: block;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(-100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* Toolbar */
.toolbar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 16px;
    display: flex;
    gap: 1.5rem;
    align-items: center;
    flex-wrap: wrap;
    justify-content: center;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    margin: 1rem 0;
}

.tool-group {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.tool-btn {
    background: linear-gradient(145deg, #f5f5f5, #e6e6e6);
    border: 2px solid transparent;
    padding: 0.75rem;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.1rem;
    color: #666;
    min-width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.tool-btn:hover {
    background: linear-gradient(145deg, #e3f2fd, #bbdefb);
    color: #2196F3;
    transform: translateY(-3px);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.3);
}

.tool-btn.active {
    background: linear-gradient(145deg, #2196F3, #1976D2);
    color: white;
    border-color: #1565C0;
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
    transform: translateY(-2px);
}

#colorPicker {
    width: 52px;
    height: 52px;
    border: 3px solid #e0e0e0;
    border-radius: 12px;
    cursor: pointer;
    background: none;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

#colorPicker:hover {
    border-color: #2196F3;
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
}

#brushSize {
    width: 100px;
    height: 8px;
    border-radius: 4px;
    background: linear-gradient(to right, #e0e0e0, #2196F3);
    outline: none;
    cursor: pointer;
    transition: all 0.3s ease;
}

#brushSize::-webkit-slider-thumb {
    appearance: none;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2196F3, #1976D2);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

#brushSize::-webkit-slider-thumb:hover {
    transform: scale(1.2);
    box-shadow: 0 4px 16px rgba(33, 150, 243, 0.4);
}

#brushSize::-moz-range-thumb {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: linear-gradient(145deg, #2196F3, #1976D2);
    cursor: pointer;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.brush-size-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.brush-size-indicator {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #2196F3;
    border: 2px solid white;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
}

/* Gallery */
.gallery-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.gallery-header h2 {
    color: white;
    font-size: 1.5rem;
}

.btn-danger {
    background: #F44336;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-danger:hover {
    background: #d32f2f;
    transform: translateY(-2px);
}

.sketch-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.sketch-item {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
}

.sketch-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2);
}

.sketch-thumbnail {
    width: 100%;
    height: 150px;
    object-fit: cover;
    background: #f5f5f5;
}

.sketch-info {
    padding: 1rem;
}

.sketch-title {
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: #333;
}

.sketch-date {
    font-size: 0.8rem;
    color: #666;
    margin-bottom: 1rem;
}

.sketch-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-small {
    padding: 0.25rem 0.5rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: all 0.3s ease;
}

.btn-load {
    background: #4CAF50;
    color: white;
}

.btn-delete {
    background: #F44336;
    color: white;
}

.btn-small:hover {
    transform: scale(1.05);
}

.empty-state {
    grid-column: 1 / -1;
    text-align: center;
    padding: 3rem;
    color: white;
    opacity: 0.7;
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
}

/* Settings */
.settings-group {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.settings-group h3 {
    color: #2196F3;
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid #eee;
}

.setting-item:last-child {
    border-bottom: none;
}

.setting-item label {
    font-weight: 500;
    color: #333;
}

.setting-item input[type="checkbox"] {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

.btn-secondary {
    background: #9C27B0;
    color: white;
    border: none;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
}

.btn-secondary:hover {
    background: #7B1FA2;
    transform: translateY(-2px);
}

/* FAQ */
.faq-container {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.faq-item {
    border-bottom: 1px solid #eee;
}

.faq-item:last-child {
    border-bottom: none;
}

.faq-question {
    width: 100%;
    background: none;
    border: none;
    padding: 1.5rem;
    text-align: left;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1rem;
    font-weight: 500;
    color: #333;
    transition: all 0.3s ease;
}

.faq-question:hover {
    background: #f8f9fa;
}

.faq-question[aria-expanded="true"] {
    background: #e3f2fd;
    color: #2196F3;
}

.faq-icon {
    font-size: 1.2rem;
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    padding: 0 1.5rem 1.5rem;
    color: #666;
    line-height: 1.6;
    animation: fadeIn 0.3s ease;
}

/* Bottom Navigation */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    padding: 0.5rem;
    display: flex;
    justify-content: space-around;
    box-shadow: 0 -2px 20px rgba(0, 0, 0, 0.1);
    z-index: 1000;
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.5rem;
    text-decoration: none;
    color: #666;
    transition: all 0.3s ease;
    border-radius: 8px;
    min-width: 60px;
}

.nav-item:hover {
    background: #f0f0f0;
    transform: translateY(-2px);
}

.nav-item.active {
    color: #2196F3;
    background: #e3f2fd;
}

.nav-item i {
    font-size: 1.2rem;
    margin-bottom: 0.25rem;
}

.nav-item span {
    font-size: 0.7rem;
    font-weight: 500;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.8rem;
    margin-top: 2rem;
}

/* Responsive Design */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.2rem;
    }
    
    .toolbar {
        padding: 1rem;
        gap: 0.75rem;
    }
    
    .tool-btn {
        padding: 0.5rem;
        min-width: 44px;
        height: 44px;
        font-size: 1rem;
    }
    
    #colorPicker {
        width: 44px;
        height: 44px;
    }
    
    #brushSize {
        width: 80px;
    }
    
    .brush-size-indicator {
        width: 16px;
        height: 16px;
    }
    
    .canvas-container {
        min-height: 300px;
        padding: 15px;
    }
    
    .sketch-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }
    
    .sketch-thumbnail {
        height: 120px;
    }
    
    .settings-group {
        padding: 1rem;
    }
    
    .faq-question {
        padding: 1rem;
        font-size: 0.9rem;
    }
}

@media (max-width: 480px) {
    main {
        padding: 0.5rem;
    }
    
    header {
        padding: 0.75rem;
    }
    
    .toolbar {
        flex-direction: column;
        gap: 1rem;
    }
    
    .tool-group {
        justify-content: center;
        width: 100%;
    }
    
    .sketch-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .gallery-header {
        flex-direction: column;
        gap: 0.5rem;
        align-items: flex-start;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .canvas-container {
        background: #1e1e1e;
    }
    
    .toolbar, .settings-group, .faq-container {
        background: rgba(30, 30, 30, 0.95);
        color: white;
    }
    
    .tool-btn {
        background: #333;
        color: #ccc;
    }
    
    .tool-btn:hover {
        background: #444;
        color: #2196F3;
    }
    
    .sketch-item {
        background: #2d2d2d;
        color: white;
    }
    
    .faq-question {
        color: white;
    }
    
    .faq-question:hover {
        background: #333;
    }
    
    .setting-item {
        border-color: #444;
    }
    
    .setting-item label {
        color: white;
    }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode */
@media (prefers-contrast: high) {
    .tool-btn, .btn-icon, .btn-secondary {
        border: 2px solid currentColor;
    }
    
    .nav-item.active {
        border: 2px solid #2196F3;
    }
}
