/* ========================================
   LAYOUT - Sidebar, Header, Content
   Professional Dark Theme
   ======================================== */

.app {
    display: flex;
    min-height: 100vh;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--sidebar-width);
    height: 100vh;
    background-color: var(--bg-secondary);
    border-right: 1px solid rgba(251, 191, 36, 0.08);
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
}

.sidebar__header {
    padding: var(--space-6);
    border-bottom: 1px solid rgba(251, 191, 36, 0.08);
}

.sidebar__logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: var(--space-3);
    text-align: center;
}

.sidebar__logo-icon {
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, var(--gold-500), var(--gold-600));
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.sidebar__logo-icon svg {
    width: 22px;
    height: 22px;
    stroke: var(--dark-950);
    stroke-width: 2;
}

.sidebar__logo-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    width: 100%;
    min-width: 0;
}

.sidebar__logo-title {
    font-family: var(--font-heading);
    font-size: 1.35rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.5px;
    line-height: 1.15;
    word-break: break-word;
    max-width: 100%;
}

.sidebar__logo-subtitle {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.4px;
    line-height: 1.3;
    word-break: break-word;
    max-width: 100%;
}

.sidebar__nav {
    flex: 1;
    padding: var(--space-5) 0;
    overflow-y: auto;
}

.sidebar__section {
    margin-bottom: var(--space-6);
}

.sidebar__section-title {
    padding: var(--space-2) var(--space-6) var(--space-3);
    font-size: 10px;
    font-weight: 700;
    color: var(--gold-500);
    text-transform: uppercase;
    letter-spacing: 2px;
}

.sidebar__menu {
    display: flex;
    flex-direction: column;
    gap: 2px;
    padding: 0 var(--space-3);
}

.sidebar__item {
    position: relative;
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: var(--dark-300);
    font-size: var(--text-sm);
    font-weight: 500;
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
    overflow: hidden;
}

.sidebar__item::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 0;
    background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
    border-radius: var(--radius-sm) 0 0 var(--radius-sm);
    transition: width var(--transition-fast);
}

.sidebar__item:hover {
    background-color: var(--dark-800);
    color: var(--text-primary);
}

.sidebar__item:hover .sidebar__item-icon svg {
    stroke: var(--text-primary);
}

.sidebar__item.active {
    background-color: rgba(251, 191, 36, 0.1);
    color: var(--gold-400);
}

.sidebar__item.active::before {
    width: 3px;
}

.sidebar__item.active .sidebar__item-icon svg {
    stroke: var(--gold-400);
}

.sidebar__item-icon {
    position: relative;
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.sidebar__item-icon svg {
    width: 18px;
    height: 18px;
    stroke: var(--dark-400);
    stroke-width: 2;
    fill: none;
    transition: stroke var(--transition-fast);
}

.sidebar__item-label {
    flex: 1;
}

.sidebar__footer {
    padding: var(--space-5) var(--space-6);
    border-top: 1px solid rgba(251, 191, 36, 0.08);
}

.sidebar__footer-line {
    width: 40px;
    height: 2px;
    background: linear-gradient(90deg, var(--gold-500), transparent);
    border-radius: 2px;
    margin-bottom: var(--space-3);
}

.sidebar__version {
    font-size: 11px;
    font-weight: 600;
    color: var(--dark-500);
    letter-spacing: 0.5px;
}

/* Sidebar Toggle Button */
.sidebar__toggle {
    position: absolute;
    right: var(--space-3);
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    background-color: var(--dark-800);
    border: 1px solid var(--dark-600);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: all var(--transition-fast);
}

.sidebar__header {
    position: relative;
}

.sidebar__header:hover .sidebar__toggle {
    opacity: 1;
}

.sidebar__toggle:hover {
    background-color: var(--dark-700);
    border-color: var(--gold-500);
}

.sidebar__toggle-icon {
    width: 16px;
    height: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar__toggle-icon svg {
    width: 14px;
    height: 14px;
    stroke: var(--dark-300);
    transition: stroke var(--transition-fast);
}

.sidebar__toggle:hover .sidebar__toggle-icon svg {
    stroke: var(--gold-400);
}

/* Sidebar Collapsed State */
.sidebar.collapsed {
    width: 72px;
}

.sidebar.collapsed .sidebar__logo-text,
.sidebar.collapsed .sidebar__section-title,
.sidebar.collapsed .sidebar__item-label,
.sidebar.collapsed .sidebar__version,
.sidebar.collapsed .sidebar__footer-line {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar__header {
    padding: var(--space-4);
    justify-content: center;
}

.sidebar.collapsed .sidebar__logo {
    justify-content: center;
}

.sidebar.collapsed .sidebar__toggle {
    position: static;
    transform: none;
    opacity: 1;
    margin-top: var(--space-3);
}

.sidebar.collapsed .sidebar__menu {
    padding: 0 var(--space-2);
}

.sidebar.collapsed .sidebar__item {
    justify-content: center;
    padding: var(--space-3);
}

.sidebar.collapsed .sidebar__item-icon {
    margin: 0;
}

.sidebar.collapsed .sidebar__section {
    margin-bottom: var(--space-4);
}

.sidebar.collapsed .sidebar__footer {
    padding: var(--space-3);
    text-align: center;
}

.main.sidebar-collapsed {
    margin-left: 72px;
}

/* ==================== SIDEBAR HISTORY ==================== */
.sidebar__section--history {
    border-top: 1px solid rgba(251, 191, 36, 0.08);
    padding-top: var(--space-4);
    margin-top: var(--space-2);
}

.sidebar__history-list {
    padding: 0 var(--space-3);
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__history-item {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-2) var(--space-4);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition-fast);
}

.sidebar__history-item:hover {
    background-color: var(--dark-800);
}

.sidebar__history-item.active {
    background-color: rgba(251, 191, 36, 0.1);
}

.sidebar__history-item.active .sidebar__history-week {
    color: var(--gold-400);
}

.sidebar__history-item.active .sidebar__history-icon svg {
    stroke: var(--gold-400);
}

.sidebar__history-icon {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.sidebar__history-icon svg {
    width: 16px;
    height: 16px;
    stroke: var(--dark-400);
    fill: none;
    transition: stroke var(--transition-fast);
}

.sidebar__history-info {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}

.sidebar__history-week {
    font-size: 11px;
    font-weight: 600;
    color: var(--dark-200);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar__history-time {
    font-size: 10px;
    color: var(--dark-500);
}

.sidebar__history-empty {
    font-size: 11px;
    font-style: italic;
    color: var(--dark-500);
    padding: var(--space-2) var(--space-4);
}

/* Sidebar collapsed - history */
.sidebar.collapsed .sidebar__history-info,
.sidebar.collapsed .sidebar__history-empty {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

.sidebar.collapsed .sidebar__history-item {
    justify-content: center;
    padding: var(--space-2);
}

.sidebar.collapsed .sidebar__history-icon {
    margin: 0;
}

/* ==================== MAIN CONTENT ==================== */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
}

.header {
    position: sticky;
    top: 0;
    height: var(--header-height);
    background-color: var(--bg-secondary);
    border-bottom: 1px solid rgba(251, 191, 36, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-8);
    z-index: var(--z-sticky);
}

.header__left {
    display: flex;
    align-items: center;
    gap: var(--space-4);
}

.header__line {
    width: 3px;
    height: 24px;
    background: linear-gradient(180deg, var(--gold-400), var(--gold-600));
    border-radius: 2px;
}

.header__title {
    font-family: var(--font-heading);
    font-size: var(--text-lg);
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.3px;
}

.header__actions {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.content {
    flex: 1;
    padding: var(--space-10) var(--space-8);
    overflow-y: auto;
}

.content__container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== PAGE HEADER ==================== */
.page-header {
    margin-bottom: var(--space-8);
}

.page-header--with-action {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: var(--space-4);
    flex-wrap: wrap;
}

.page-header__top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-2);
}

.page-header__title {
    font-family: var(--font-heading);
    font-size: var(--text-2xl);
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.page-header__subtitle {
    display: flex;
    align-items: center;
    gap: var(--space-3);
}

.page-header__subtitle::before {
    content: "";
    width: 32px;
    height: 2px;
    background: var(--gold-500);
    border-radius: 2px;
}

.page-header__subtitle-text {
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--dark-300);
}

/* ==================== PAGES ==================== */
.page {
    display: none;
}

.page.active {
    display: block;
    animation: fadeIn var(--transition-base) ease-out;
}

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

/* ==================== HAMBURGER BUTTON ==================== */
.header__hamburger {
    display: none;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--dark-200);
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.header__hamburger:hover {
    background-color: var(--dark-800);
    color: var(--gold-400);
}

.header__hamburger-icon {
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header__hamburger-icon svg {
    width: 22px;
    height: 22px;
    stroke: currentColor;
}

/* ==================== SIDEBAR BACKDROP ==================== */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: calc(var(--z-sticky) - 1);
    opacity: 0;
    transition: opacity var(--transition-base);
}

.sidebar-backdrop.active {
    display: block;
    opacity: 1;
}

/* ==================== THEME TOGGLE ==================== */
.header__theme-toggle {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-sm);
    background-color: var(--bg-elevated);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    -webkit-tap-highlight-color: transparent;
}

.header__theme-toggle:hover {
    background-color: var(--bg-hover);
    color: var(--gold-500);
    border-color: var(--gold-500);
}

.header__theme-icon {
    width: 18px;
    height: 18px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header__theme-icon svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    fill: none;
}

/* ==================== RESPONSIVE ==================== */
@media (max-width: 1024px) {
    .header__hamburger {
        display: flex;
    }

    .header__line {
        display: none;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform var(--transition-base);
        z-index: calc(var(--z-sticky) + 2);
    }
    .sidebar.open {
        transform: translateX(0);
    }
    .sidebar-backdrop {
        z-index: calc(var(--z-sticky) + 1);
    }
    .sidebar.collapsed {
        width: var(--sidebar-width);
        transform: translateX(-100%);
    }
    .sidebar.collapsed.open {
        transform: translateX(0);
    }
    .sidebar.collapsed .sidebar__logo-text,
    .sidebar.collapsed .sidebar__section-title,
    .sidebar.collapsed .sidebar__item-label,
    .sidebar.collapsed .sidebar__version,
    .sidebar.collapsed .sidebar__footer-line,
    .sidebar.collapsed .sidebar__history-info,
    .sidebar.collapsed .sidebar__history-empty {
        opacity: 1;
        width: auto;
    }
    .sidebar.collapsed .sidebar__item {
        justify-content: flex-start;
        padding: var(--space-3) var(--space-4);
    }
    .sidebar.collapsed .sidebar__history-item {
        justify-content: flex-start;
        padding: var(--space-2) var(--space-4);
    }
    .sidebar__toggle {
        display: none;
    }
    .main {
        margin-left: 0 !important;
    }
    .content {
        padding: var(--space-6);
    }
}

@media (max-width: 768px) {
    .header {
        padding: 0 var(--space-3);
        height: 56px;
    }
    .header__title {
        font-size: var(--text-base);
    }
    .header__actions {
        gap: var(--space-2);
    }
    .header__theme-toggle {
        width: 40px;
        height: 40px;
    }
    .header__theme-icon,
    .header__theme-icon svg {
        width: 20px;
        height: 20px;
    }
    .header__actions #btn-salvar-header {
        padding: 0 var(--space-3);
        height: 36px;
    }
    .header__actions #btn-salvar-header span:not(.btn__icon) {
        display: none;
    }
    .content {
        padding: var(--space-3);
    }
    .page-header {
        margin-bottom: var(--space-5);
    }
    .page-header__title {
        font-size: var(--text-xl);
    }
    .page-header__subtitle {
        font-size: var(--text-xs);
    }
}
