/* CSS Custom Properties */
:root {
    --primary-color: #7868E6;
    --secondary-color: #B8B5FF;
    --accent-color: #FFB4B4;
    --background-light: #EDEEF7;
    --background-accent: #E4FBFF;
    --text-dark: #2c3e50;
    --text-light: #6c757d;
    --white: #ffffff;
    --success: #28a745;
    --error: #dc3545;
    --warning: #ffc107;
    --border-radius: 8px;
    --box-shadow: 0 2px 10px rgba(120, 104, 230, 0.1);
    --transition: all 0.3s ease;
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

/* Dark Theme Variables */
html.dark {
    --primary-color: #9aa5ff;
    --secondary-color: #6b6eff;
    --accent-color: #ff9db3;
    --background-light: #1f2430;
    --background-accent: #171a24;
    --text-dark: #e6e6e6;
    --text-light: #aeb4c0;
    --white: #0f121a;
    --success: #51d88a;
    --error: #ff6b6b;
    --warning: #ffd166;
    --box-shadow: 0 2px 12px rgba(0, 0, 0, 0.35);
}

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

body {
    font-family: var(--font-family);
    line-height: 1.6;
    color: var(--text-dark);
    background: linear-gradient(135deg, var(--background-light) 0%, var(--background-accent) 100%);
    min-height: 100vh;
    position: relative;
}

/* Paper Texture Effect */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image: 
        radial-gradient(circle at 1px 1px, rgba(255,255,255,0.3) 1px, transparent 0);
    background-size: 20px 20px;
    pointer-events: none;
    z-index: -1;
}

/* Chrome, Edge - remove ícone de validação */
input:invalid,
select:invalid,
textarea:invalid {
    box-shadow: none !important;
}

/* Remove ícone visual padrão do Chrome */
input::-webkit-validation-bubble-message,
input::-webkit-inner-spin-button,
select::-webkit-validation-bubble-message {
    display: none !important;
}

/* Safari - remove ícones de validação */
input:invalid::-webkit-input-placeholder {
    color: inherit;
}

/* Firefox - remove ícone e estilo de erro */
input:invalid {
    box-shadow: none;
}


/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
    padding: 2rem 0;
    text-align: center;
    box-shadow: var(--box-shadow);
    position: relative;
}

.header__title {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.header__logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

@keyframes bounce {
    0%, 20%, 50%, 80%, 100% { transform: translateY(0); }
    40% { transform: translateY(-10px); }
    60% { transform: translateY(-5px); }
}

.header__subtitle {
    font-size: 1.2rem;
    opacity: 0.9;
    font-weight: 300;
}

/* Minimal Theme Toggle */
.theme-toggle {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(0, 0, 0, 0.28);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.45);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    line-height: 1;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    opacity: 1;
    transition: var(--transition);
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.theme-toggle:hover {
    border-color: rgba(255,255,255,0.65);
    background: rgba(0, 0, 0, 0.38);
}

.theme-toggle:focus {
    outline: 2px solid rgba(255,255,255,0.4);
    outline-offset: 2px;
}

/* Navigation */
.navigation {
    background: var(--primary-color);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navigation__list {
    list-style: none;
    display: flex;
    justify-content: center;
    padding: 1rem 0;
}

.navigation__item {
    margin: 0 1rem;
}

.navigation__link {
    text-decoration: none;
    color: var(--text-dark);
    font-weight: 500;
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
    position: relative;
}

.navigation__link:hover,
.navigation__link--active {
    background: var(--secondary-color);
    color: var(--white);
    transform: translateY(-2px);
}

/* Main Content */
.main {
    padding: 2rem 0;
    min-height: calc(100vh - 200px);
}

.app-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2rem;
    align-items: start;
}

/* Card Component */
.card {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 2rem;
    box-shadow: var(--box-shadow);
    margin-bottom: 2rem;
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color), var(--secondary-color));
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(120, 104, 230, 0.15);
}

.card__title {
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    color: var(--primary-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.card__title::before {
    
    font-size: 1.2rem;
}

/* Form Styles */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.form__group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form__label {
    font-weight: 600;
    color: var(--text-dark);
    font-size: 0.9rem;
}

.form__input,
.form__select {
    padding: 0.75rem;
    border: 2px solid #e1e5e9;
    border-radius: var(--border-radius);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--white);
}

.form__input:focus,
.form__select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(120, 104, 230, 0.1);
}

.form__input:invalid:not(:placeholder-shown) {
    border-color: var(--error);
}

.form__input:valid:not(:placeholder-shown) {
    border-color: var(--success);
}

.form__error {
    color: var(--error);
    font-size: 0.8rem;
    min-height: 1.2rem;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.form__error::before {
    font-size: 0.8rem;
}

.form__actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    position: relative;
    overflow: hidden;
}

.btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.2), transparent);
    transition: left 0.5s;
}

.btn:hover::before {
    left: 100%;
}

.btn--primary {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: var(--white);
}

.btn--primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(120, 104, 230, 0.3);
}

.btn--secondary {
    background: var(--background-light);
    color: var(--text-dark);
}

.btn--secondary:hover {
    background: var(--secondary-color);
    color: var(--white);
}

.btn--success {
    background: linear-gradient(135deg, var(--success), #20c997);
    color: var(--white);
}

.btn--success:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(40, 167, 69, 0.3);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.btn:disabled:hover {
    transform: none;
    box-shadow: none;
}

/* Preview Section */
.preview-container {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
    padding: 1rem;
    background: var(--background-light);
    border-radius: var(--border-radius);
}

.preview-canvas {
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    box-shadow: var(--box-shadow);
    width: 100%;
    max-width: 400px;
    height: auto;
}

.preview-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
}

/* Saved Labels */
.saved-labels {
    max-height: 300px;
    overflow-y: auto;
}

.saved-labels__empty {
    text-align: center;
    color: var(--text-light);
    font-style: italic;
    padding: 2rem;
}

.saved-label {
    background: var(--background-light);
    border-radius: var(--border-radius);
    padding: 1rem;
    margin-bottom: 1rem;
    border-left: 4px solid var(--primary-color);
    transition: var(--transition);
}

.saved-label:hover {
    background: var(--background-accent);
    transform: translateX(5px);
}

.saved-label__header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.saved-label__name {
    font-weight: 600;
    color: var(--primary-color);
}

.saved-label__date {
    font-size: 0.8rem;
    color: var(--text-light);
}

.saved-label__details {
    font-size: 0.9rem;
    color: var(--text-dark);
    line-height: 1.4;
}

.saved-label__actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.btn--small {
    padding: 0.3rem 0.8rem;
    font-size: 0.8rem;
}

.btn--danger {
    background: var(--error);
    color: var(--white);
}

.btn--danger:hover {
    background: #c82333;
}

/* Footer */
.footer {
    background: var(--primary-color);
    color: var(--white);
    text-align: center;
    padding: 1.5rem 0;
    margin-top: 2rem;
}

.footer__text {
    font-size: 0.9rem;
    opacity: 0.9;
}

.footer__link {
    color: var(--secondary-color);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}

.footer__link:hover {
    color: var(--white);
    text-decoration: underline;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 5px solid var(--background-light);
    border-top: 5px solid var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.loading-text {
    color: var(--white);
    margin-top: 1rem;
    font-size: 1.1rem;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1001;
}

.toast {
    background: var(--white);
    border-radius: var(--border-radius);
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    box-shadow: var(--box-shadow);
    border-left: 4px solid var(--primary-color);
    animation: slideIn 0.3s ease-out;
    max-width: 300px;
}

.toast--success {
    border-left-color: var(--success);
}

.toast--error {
    border-left-color: var(--error);
}

.toast--warning {
    border-left-color: var(--warning);
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .container {
        padding: 0 15px;
    }
    
    .header__title {
        font-size: 2rem;
        flex-direction: column;
        gap: 0.5rem;
    }
    
    .header__icon {
        font-size: 2rem;
    }
    
    .app-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .card {
        padding: 1.5rem;
    }
    
    .form__actions {
        flex-direction: column;
    }
    
    .preview-actions {
        flex-direction: column;
    }
    
    .navigation__list {
        flex-direction: column;
        align-items: center;
        gap: 0.5rem;
    }
    
    .saved-label__header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
    }
    
    .saved-label__actions {
        flex-wrap: wrap;
    }
}

@media (max-width: 480px) {
    .header {
        padding: 1.5rem 0;
    }
    
    .header__title {
        font-size: 1.8rem;
    }
    
    .header__subtitle {
        font-size: 1rem;
    }
    
    .card {
        padding: 1rem;
    }
    
    .preview-canvas {
        width: 100%;
        max-width: 100%;
        height: auto;
    }
    
    .toast-container {
        left: 10px;
        right: 10px;
    }
    
    .toast {
        max-width: none;
    }
}

/* Print Styles Preview */
@media screen {
    .print-preview {
        background: var(--white);
        padding: 2rem;
        border-radius: var(--border-radius);
        box-shadow: var(--box-shadow);
    }
}

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

/* Focus Styles */
.btn:focus,
.form__input:focus,
.form__select:focus,
.navigation__link:focus {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    :root {
        --primary-color: #000080;
        --secondary-color: #4169E1;
        --text-dark: #000000;
        --text-light: #333333;
    }
}
