:root {
    --sidebar-width: 280px;
    --header-height: 60px;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #0f172a;
    color: #e2e8f0;
    margin: 0;
    padding: 0;
}

/* Layout Principal */
#app {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background-color: #1e293b;
    transition: transform 0.3s ease;
    z-index: 50;
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
}

.main-content {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.3s ease;
    background-color: #0f172a;
    flex: 1;
    min-height: 100vh;
}

/* Sidebar Styles */
.sidebar-top {
    padding: 1.5rem 1rem 1rem;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: #e2e8f0;
}

.logo-icon {
    font-size: 1.5rem;
    color: #3b82f6;
}

.divider {
    border: none;
    border-top: 1px solid #334155;
    margin: 1rem 0;
}

.menu-list {
    list-style: none;
    padding: 0;
    margin: 0;
    flex: 1;
}

.menu-item {
    width: 100%;
    padding: 0.75rem 1rem;
    border: none;
    background: none;
    color: #e2e8f0;
    text-align: left;
    border-radius: 0.375rem;
    margin-bottom: 0.25rem;
    transition: background-color 0.2s;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    font-size: 0.95rem;
}

.menu-item:hover,
.menu-item.active {
    background-color: #334155;
}

.menu-item i {
    width: 20px;
    text-align: center;
}

.sidebar-bottom {
    padding: 1rem;
}

.btn-exit {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #e2e8f0;
    text-decoration: none;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-exit:hover {
    background-color: #334155;
}

/* Header */
.topbar {
    display: flex;
    align-items: center;
    padding: 1rem 1.5rem;
    background-color: #1e293b;
    border-bottom: 1px solid #334155;
    height: var(--header-height);
    box-sizing: border-box;
}

.btn-menu-toggle {
    display: none;
    background: none;
    border: none;
    color: #e2e8f0;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
}

.btn-menu-toggle:hover {
    background-color: #334155;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin: 0;
    color: #e2e8f0;
}

.spacer {
    flex: 1;
}

.storage-indicators {
    display: flex;
    gap: 1rem;
    font-size: 0.875rem;
    color: #94a3b8;
}

/* Content Area */
.content {
    padding: 2rem;
}

.view {
    max-width: 600px;
    margin: 0 auto;
}

.hidden {
    display: none;
}

/* Form Styles */
.form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

label {
    font-weight: 600;
    color: #e2e8f0;
    margin-bottom: 0.5rem;
    display: block;
}

input {
    width: 100%;
    padding: 0.75rem;
    border-radius: 0.375rem;
    background: #334155;
    color: #e2e8f0;
    border: 1px solid #475569;
    font-size: 1rem;
    box-sizing: border-box;
}

input:focus {
    outline: none;
    border-color: #3b82f6;
    background: #374151;
}

.form-actions {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 0.375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 1rem;
}

.btn.primary {
    background: #3b82f6;
    color: white;
}

.btn.primary:hover {
    background: #2563eb;
}

.btn:not(.primary) {
    background: #64748b;
    color: white;
}

.btn:not(.primary):hover {
    background: #475569;
}

/* Result Styles */
.result {
    margin-top: 2rem;
    padding: 1.5rem;
    background: #1e293b;
    border-radius: 0.75rem;
    border-left: 4px solid #3b82f6;
}

.result div {
    padding: 0.5rem 0;
    font-size: 1.1rem;
}

.result div:not(:last-child) {
    border-bottom: 1px solid #334155;
}

/* Error Styles */
.field-error {
    color: #ef4444;
    font-size: 0.875rem;
    margin-top: 0.5rem;
    min-height: 1.25rem;
}

/* Toast Styles */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: #1e293b;
    color: #e2e8f0;
    padding: 1rem 1.5rem;
    border-radius: 0.75rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 1rem;
    z-index: 1000;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s ease;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-close {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.25rem;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 0.25rem;
    transition: color 0.2s;
}

.toast-close:hover {
    color: #e2e8f0;
}

/* Overlay para mobile */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 998;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
}

/* ============ MELHORIAS PARA MOBILE ============ */

@media (max-width: 768px) {
    .sidebar {
        width: 85%;
        max-width: 300px;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 15px rgba(0, 0, 0, 0.3);
        z-index: 999;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
        width: 100%;
    }
    
    .btn-menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 44px;
        height: 44px;
    }
    
    .topbar {
        padding: 0.75rem 1rem;
        height: auto;
        min-height: 60px;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .page-title {
        font-size: 1.25rem;
        margin: 0 1rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }
    
    .content {
        padding: 1rem;
    }
    
    .view {
        padding: 1rem 0;
        max-width: none;
    }
    
    h2 {
        font-size: 1.5rem;
        margin-bottom: 1.5rem;
        text-align: center;
    }
    
    .form {
        gap: 1.25rem;
    }
    
    label {
        margin-bottom: 0.5rem;
    }
    
    input {
        padding: 1rem;
        border: 2px solid #475569;
        border-radius: 8px;
        font-size: 16px;
        min-height: 52px;
    }
    
    input:focus {
        border-color: #3b82f6;
        background: #374151;
    }
    
    input[type="number"] {
        -moz-appearance: textfield;
        appearance: textfield;
    }
    
    input::-webkit-outer-spin-button,
    input::-webkit-inner-spin-button {
        -webkit-appearance: none;
        margin: 0;
    }
    
    .form-actions {
        gap: 0.75rem;
        margin-top: 1rem;
    }
    
    .btn {
        flex: 1;
        padding: 1rem 1.5rem;
        border-radius: 8px;
        font-size: 1rem;
        min-height: 52px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    .btn.primary:active {
        background: #2563eb;
        transform: translateY(1px);
    }
    
    .btn:not(.primary):active {
        background: #475569;
        transform: translateY(1px);
    }
    
    .result {
        margin-top: 1.5rem;
        padding: 1.25rem;
        border-radius: 12px;
    }
    
    .result div {
        padding: 0.5rem 0;
        font-size: 1.1rem;
        font-weight: 500;
    }
    
    .result div:not(:last-child) {
        border-bottom: 1px solid #334155;
    }
    
    .toast {
        bottom: 1rem;
        left: 1rem;
        right: 1rem;
        max-width: none;
        border-radius: 12px;
        padding: 1rem;
    }
    
    .storage-indicators {
        display: none;
    }
    
    .menu-item {
        padding: 1rem 1.25rem;
        margin-bottom: 0.5rem;
        border-radius: 8px;
        font-size: 1rem;
        min-height: 52px;
    }
    
    .menu-item i {
        font-size: 1.2rem;
        width: 24px;
    }
    
    .btn-exit {
        padding: 1rem 1.25rem;
        border-radius: 8px;
        font-size: 1rem;
        min-height: 52px;
    }
    
    /* Prevenir zoom desnecessário em inputs no iOS */
    input, select, textarea {
        font-size: 16px;
    }
    
    /* Suporte a dispositivos com notch */
    @supports(padding: max(0px)) {
        .content {
            padding-left: max(1rem, env(safe-area-inset-left));
            padding-right: max(1rem, env(safe-area-inset-right));
            padding-bottom: max(1rem, env(safe-area-inset-bottom));
        }
        
        .topbar {
            padding-top: max(0.75rem, env(safe-area-inset-top));
        }
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .sidebar {
        width: 240px;
    }
    
    .main-content {
        margin-left: 240px;
    }
    
    .content {
        padding: 1.5rem;
    }
    
    .form {
        max-width: 500px;
        margin: 0 auto;
    }
    
    .btn {
        min-height: 48px;
    }
    
    input {
        min-height: 48px;
    }
}

/* Desktop - garantir que as melhorias mobile não afetem o desktop */
@media (min-width: 1025px) {
    .sidebar-overlay {
        display: none;
    }
    
    .btn-menu-toggle {
        display: none;
    }
}
/* Estilos para o botão Voltar ao Dashboard */
.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid #334155;
    margin-top: auto;
}

.sidebar-link.exit-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: #e2e8f0;
    text-decoration: none;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    font-size: 0.95rem;
    text-align: left;
}

.sidebar-link.exit-btn:hover {
    background-color: #334155;
}

/* Mobile styles */
@media (max-width: 768px) {
    .sidebar-footer {
        padding: 1rem 1.25rem;
    }
    
    .sidebar-link.exit-btn {
        padding: 1rem 1.25rem;
        border-radius: 8px;
        font-size: 1rem;
        min-height: 52px;
    }
}