@import 'variables.css';
@import 'components.css';
@import 'tablet.css';

/* Reset */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    min-height: 100vh;
}

/* Applied temporarily during theme switch so only the toggle pays the transition cost */
.theme-animating,
.theme-animating * {
    transition: background-color 300ms ease, color 300ms ease, border-color 300ms ease !important;
}

a {
    color: inherit;
    text-decoration: none;
}

/* App Layout */
#app {
    display: flex;
    min-height: 100vh;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 100vh;
    position: relative;
    overflow: hidden;
    background: var(--bg-primary);
    flex: 1;
}

/* Animated ambient background orbs */
.login-page::before,
.login-page::after {
    content: '';
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    opacity: 0.35;
    animation: login-orb-float 8s ease-in-out infinite alternate;
    pointer-events: none;
}

.login-page::before {
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(245, 158, 11, 0.35) 0%, transparent 70%);
    top: -10%;
    left: -5%;
    animation-delay: 0s;
}

.login-page::after {
    width: 400px;
    height: 400px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.22) 0%, transparent 70%);
    bottom: -10%;
    right: -5%;
    animation-delay: -4s;
}

@keyframes login-orb-float {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(30px, -20px) scale(1.08); }
}

@keyframes login-card-appear {
    0% {
        opacity: 0;
        transform: translateY(20px) scale(0.98);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: var(--space-lg);
    position: relative;
    z-index: 1;
}

/* Glassmorphism card */
.login-card {
    background: rgba(23, 28, 20, 0.55);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-top: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: var(--radius-xl);
    padding: var(--space-2xl);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(245, 158, 11, 0.06),
        inset 0 1px 0 rgba(255, 255, 255, 0.05);
    position: relative;
    overflow: hidden;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* Subtle top glow line */
.login-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 15%;
    right: 15%;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.4), transparent);
    pointer-events: none;
}

/* Inner subtle gradient overlay */
.login-card::after {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: radial-gradient(ellipse at 50% 0%, rgba(245, 158, 11, 0.04) 0%, transparent 60%);
    pointer-events: none;
}

.login-header {
    text-align: center;
    margin-bottom: var(--space-xl);
    position: relative;
    z-index: 1;
}

.login-logo {
    font-size: 48px;
    margin-bottom: var(--space-md);
}

.login-logo-img {
    max-width: 100px;
    height: auto;
    margin-bottom: var(--space-md);
    filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.3));
}

.login-title {
    font-family: var(--font-display);
    font-size: 26px;
    font-weight: 700;
    margin-bottom: var(--space-xs);
    background: linear-gradient(135deg, var(--text-primary) 0%, var(--color-primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.login-subtitle {
    color: var(--text-secondary);
    font-size: 14px;
    letter-spacing: 0.02em;
}

/* Glassmorphism inputs */
.login-form .form-group {
    margin-bottom: var(--space-lg);
    position: relative;
    z-index: 1;
}

.login-form .form-input {
    background: rgba(27, 33, 24, 0.6);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: var(--radius-md);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all var(--transition-fast);
}

.login-form .form-input:focus {
    border-color: var(--color-primary-border);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.12), inset 0 1px 0 rgba(255, 255, 255, 0.05);
    background: rgba(27, 33, 24, 0.8);
    outline: none;
}

.login-form .form-label {
    color: var(--text-secondary);
    font-size: 13px;
    font-weight: 500;
    margin-bottom: var(--space-xs);
    display: block;
}

.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 16px;
    font-weight: 600;
    border-radius: var(--radius-md);
    position: relative;
    z-index: 1;
    overflow: hidden;
    transition: all var(--transition-fast);
    box-shadow: 0 4px 16px rgba(245, 158, 11, 0.25);
}

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

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

.login-btn:hover {
    box-shadow: 0 6px 24px rgba(245, 158, 11, 0.35);
    transform: translateY(-1px);
}

.login-btn:active {
    transform: translateY(0);
}

/* Light mode glassmorphism adjustments */
body.light-mode .login-card {
    background: rgba(255, 255, 255, 0.65);
    border-color: rgba(255, 255, 255, 0.5);
    border-top-color: rgba(255, 255, 255, 0.7);
    box-shadow:
        0 8px 32px rgba(14, 26, 12, 0.12),
        0 0 0 1px rgba(245, 158, 11, 0.08),
        inset 0 1px 0 rgba(255, 255, 255, 0.6);
}

body.light-mode .login-card::before {
    background: linear-gradient(90deg, transparent, rgba(245, 158, 11, 0.3), transparent);
}

body.light-mode .login-form .form-input {
    background: rgba(255, 255, 255, 0.5);
    border-color: rgba(14, 26, 12, 0.08);
}

body.light-mode .login-form .form-input:focus {
    background: rgba(255, 255, 255, 0.8);
    border-color: var(--color-primary-border);
}

body.light-mode .login-page::before {
    background: radial-gradient(circle, rgba(245, 158, 11, 0.2) 0%, transparent 70%);
}

body.light-mode .login-page::after {
    background: radial-gradient(circle, rgba(16, 185, 129, 0.12) 0%, transparent 70%);
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--bg-secondary);
    background-image: linear-gradient(180deg, rgba(245, 158, 11, 0.03) 0%, transparent 35%);
    border-right: 1px solid var(--border-color);
    position: fixed;
    left: 0;
    top: 0;
    display: flex;
    flex-direction: column;
    transition: width var(--transition-normal), transform var(--transition-normal);
    z-index: 100;
}

.sidebar-header {
    padding: 6px var(--space-lg) var(--space-lg);
    border-bottom: 1px solid var(--border-color);
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.06) 0%, transparent 80%);
    position: relative;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: var(--space-md);
}

.sidebar-logo {
    font-size: 28px;
}

.sidebar-logos {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
}

.sidebar-logos-mini {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 4px;
}

.sidebar-logo-mini-img {
    width: 46px;
    height: auto;
    display: block;
}

.sidebar-logo-img {
    height: auto;
    display: block;
}

.sidebar-logo-basilic {
    max-width: 80px;
}

.sidebar-logo-chocolataria {
    max-width: 80px;
}


.sidebar-title {
    font-size: 16px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: var(--space-lg);
}

.sidebar-section-title {
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--space-sm) var(--space-md);
    margin-bottom: var(--space-xs);
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
    position: relative;
    cursor: pointer;
}

.sidebar-link:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.sidebar-link.active {
    background: var(--color-primary-dim);
    color: var(--color-primary);
    font-weight: 600;
}

.sidebar-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 5px;
    bottom: 5px;
    width: 3px;
    background: var(--color-primary);
    border-radius: 0 3px 3px 0;
}

.sidebar-link-icon {
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: inherit;
    opacity: 0.7;
    transition: opacity 0.15s;
}

.sidebar-link:hover .sidebar-link-icon,
.sidebar-link.active .sidebar-link-icon {
    opacity: 1;
}

.sidebar-link-icon svg {
    width: 22px;
    height: 22px;
}

.sidebar-link-badge {
    margin-left: auto;
    background: var(--color-error);
    color: white;
    font-size: 11px;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 9999px;
}

.btn-logout {
    color: var(--color-error);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.15);
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border-color);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: var(--space-md);
    padding: var(--space-sm);
}

.sidebar-user-avatar {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 14px;
    color: #0C0E0B;
    flex-shrink: 0;
}

.sidebar-user-info {
    flex: 1;
    min-width: 0;
}

.sidebar-user-name {
    font-size: 14px;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.sidebar-user-role {
    font-size: 12px;
    color: var(--text-secondary);
}

/* Theme Toggle - Inspired by Magic UI */
.theme-toggle-wrapper {
    margin-bottom: var(--space-md);
    display: flex;
    justify-content: center;
}

.theme-toggle {
    position: relative;
    width: 60px;
    height: 32px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 9999px;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    padding: 0 4px;
    overflow: hidden;
    backdrop-filter: blur(10px);
}

.theme-toggle:hover {
    background: var(--bg-hover);
    border-color: var(--color-primary);
    box-shadow: 0 0 0 1px var(--color-primary);
}

.theme-toggle:active {
    transform: scale(0.95);
}

.theme-toggle-icons {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 8px;
    font-size: 14px;
    pointer-events: none;
    z-index: 0;
}

.theme-toggle-icons span {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-primary);
}

.theme-toggle-icons span:first-child {
    opacity: 0.3;
    transform: scale(0.8) rotate(-20deg);
}

.theme-toggle-icons span:last-child {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

body.light-mode .theme-toggle {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.1), rgba(255, 165, 0, 0.1));
}

body.light-mode .theme-toggle-icons span:first-child {
    opacity: 1;
    transform: scale(1) rotate(0deg);
}

body.light-mode .theme-toggle-icons span:last-child {
    opacity: 0.3;
    transform: scale(0.8) rotate(20deg);
}

.theme-toggle-knob {
    width: 24px;
    height: 24px;
    background: linear-gradient(135deg, var(--text-primary), var(--text-secondary));
    border-radius: 50%;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    z-index: 1;
    box-shadow:
        0 2px 8px rgba(0, 0, 0, 0.15),
        inset 0 1px 1px rgba(255, 255, 255, 0.2);
    will-change: transform;
}

body.light-mode .theme-toggle-knob {
    transform: translateX(28px);
    background: linear-gradient(135deg, #ffd700, #ffa500);
    box-shadow:
        0 2px 12px rgba(255, 165, 0, 0.4),
        inset 0 1px 1px rgba(255, 255, 255, 0.5);
}

/* Add subtle animation on theme change */
@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.4);
    }
    50% {
        box-shadow: 0 0 0 4px rgba(59, 130, 246, 0);
    }
}

.theme-toggle:active::before {
    content: '';
    position: absolute;
    inset: -2px;
    border-radius: 9999px;
    animation: pulse-glow 0.6s ease-out;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-collapsed);
    transition: margin-left var(--transition-normal);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    background: var(--bg-primary);
}

/* Header */
.header {
    height: var(--header-height);
    background: var(--header-bg, rgba(20, 24, 18, 0.88));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 var(--space-lg);
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow:
        0 1px 0 var(--border-color),
        0 4px 24px rgba(0, 0, 0, 0.35);
}

/* Amber gradient line along the bottom */
.header::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 260px;
    height: 1px;
    background: linear-gradient(90deg, var(--color-primary) 0%, rgba(245, 158, 11, 0.18) 60%, transparent 100%);
    pointer-events: none;
}

.header-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.01em;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Glowing amber dot before the page title */
.header-title::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--color-primary);
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.8), 0 0 16px rgba(245, 158, 11, 0.3);
    flex-shrink: 0;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
}

/* Hamburger button — hidden on desktop, shown on tablet/mobile */
.mobile-menu-btn {
    display: none;
    align-items: center;
    justify-content: center;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    flex-shrink: 0;
    color: var(--text-primary);
}

/* Sidebar backdrop overlay */
#sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

#sidebar-overlay.active {
    display: block;
}

/* Logout button in header — hidden on desktop */
.mobile-logout-btn {
    display: none;
}

.header-alert-btn {
    position: relative;
    border: 1px solid var(--border-light) !important;
    background: var(--bg-tertiary) !important;
    border-radius: var(--radius-md) !important;
    color: var(--text-primary) !important;
    transition: background var(--transition-fast), border-color var(--transition-fast), box-shadow var(--transition-fast) !important;
}

.header-alert-btn:hover {
    background: var(--bg-hover) !important;
    border-color: var(--color-primary-border) !important;
    box-shadow: 0 0 12px rgba(245, 158, 11, 0.15) !important;
}

.header-alert-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 18px;
    height: 18px;
    background: var(--color-error);
    color: white;
    font-size: 10px;
    font-weight: 700;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Page Content */
.page-content {
    flex: 1;
    padding: var(--space-lg);
}

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

.page-title {
    font-family: var(--font-display);
    font-size: 24px;
    font-weight: 700;
}

.page-actions {
    display: flex;
    gap: var(--space-sm);
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: var(--space-lg);
    margin-bottom: var(--space-lg);
}

.dashboard-section {
    margin-bottom: var(--space-xl);
}

.dashboard-bottom-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--space-lg);
}

.dashboard-section-title {
    font-family: var(--font-display);
    font-size: 18px;
    font-weight: 700;
    margin-bottom: var(--space-md);
}

/* Pedido Card */
.pedido-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: var(--space-lg);
    margin-bottom: var(--space-md);
}

.pedido-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-md);
}

.pedido-numero {
    font-size: 16px;
    font-weight: 600;
}

.pedido-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: var(--space-md);
    margin-bottom: var(--space-md);
    padding-bottom: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

.pedido-info-item {
    font-size: 14px;
}

.pedido-info-label {
    color: var(--text-secondary);
    font-size: 12px;
    margin-bottom: 2px;
}

.pedido-itens {
    margin-bottom: var(--space-md);
}

.pedido-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border-color);
}

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

.pedido-actions {
    display: flex;
    gap: var(--space-sm);
    justify-content: flex-end;
}

/* Item List for Orders */
.pedido-item-list {
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-md);
}

.pedido-item-row {
    display: grid;
    grid-template-columns: 1fr 100px 80px auto;
    gap: var(--space-md);
    align-items: center;
    padding: var(--space-md);
    border-bottom: 1px solid var(--border-color);
}

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

/* Stock Item */
.stock-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-xs);
}

.stock-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.stock-dot.ok {
    background: var(--color-success);
}

.stock-dot.low {
    background: var(--color-warning);
}

.stock-dot.empty {
    background: var(--color-error);
}

/* Filters */
.filters {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-md);
    margin-bottom: var(--space-lg);
    padding: var(--space-md);
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: var(--space-xs);
}

.filter-group label {
    font-size: 12px;
    color: var(--text-secondary);
}

.filter-group select,
.filter-group input {
    min-width: 150px;
}

/* ── Desktop Sidebar: collapsed by default, expand on hover ───────────── */
@media (min-width: 1025px) {
    .sidebar {
        width: var(--sidebar-collapsed);
        overflow: hidden;
    }

    .sidebar:hover {
        width: var(--sidebar-width);
    }

    .sidebar:hover ~ .main-content {
        margin-left: var(--sidebar-width);
    }

    /* Link labels fade in */
    .sidebar-label {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        white-space: nowrap;
        transition: max-width var(--transition-normal), opacity 0.15s ease;
        display: inline-block;
    }

    .sidebar:hover .sidebar-label {
        max-width: 200px;
        opacity: 1;
    }

    /* Section titles collapse */
    .sidebar-section-title {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        padding-top: 0;
        padding-bottom: 0;
        margin: 0;
        transition: max-height var(--transition-normal), opacity 0.15s ease,
                    padding var(--transition-normal), margin var(--transition-normal);
    }

    .sidebar:hover .sidebar-section-title {
        max-height: 30px;
        opacity: 1;
        padding: var(--space-sm) var(--space-md);
        margin-bottom: var(--space-xs);
    }

    /* Header: flush to top-left when collapsed */
    .sidebar-header {
        padding: 0 0 0 2px;
        border-bottom: none;
        transition: padding var(--transition-normal);
        align-items: flex-start;
    }

    .sidebar:hover .sidebar-header {
        padding: 6px var(--space-lg) var(--space-lg);
        border-bottom: 1px solid var(--border-color);
    }

    /* Full logos: always hidden on desktop (mini logos used instead) */
    .sidebar-logos {
        display: none;
    }

    /* Mini logos: always visible, centered */
    .sidebar-logos-mini {
        position: absolute;
        top: 6px;
        left: 50%;
        transform: translateX(-50%);
        opacity: 1;
        transition: top var(--transition-normal);
    }

    .sidebar:hover .sidebar-logos-mini {
        top: 20px;
    }

    /* Nav: fixed padding, no movement on expand */
    .sidebar-nav {
        padding-top: 90px;
        padding-left: 0;
        padding-right: 0;
    }

    .sidebar-link {
        justify-content: flex-start;
        padding-left: 16px;
        padding-right: 0;
    }

    .sidebar:hover .sidebar-link {
        padding-right: var(--space-md);
    }

    /* Remove category gaps when collapsed */
    .sidebar-section {
        margin-bottom: 0;
        transition: margin-bottom var(--transition-normal);
    }

    .sidebar:hover .sidebar-section {
        margin-bottom: var(--space-lg);
    }

    /* User info collapses */
    .sidebar-user-info {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-width var(--transition-normal), opacity 0.15s ease;
    }

    .sidebar:hover .sidebar-user-info {
        max-width: 200px;
        opacity: 1;
    }

    /* Logout button collapses */
    .btn-logout {
        max-width: 0;
        opacity: 0;
        overflow: hidden;
        transition: max-width var(--transition-normal), opacity 0.15s ease;
    }

    .sidebar:hover .btn-logout {
        max-width: 40px;
        opacity: 1;
    }

    /* Theme toggle collapses */
    .theme-toggle-wrapper {
        max-height: 0;
        opacity: 0;
        overflow: hidden;
        margin-bottom: 0;
        transition: max-height var(--transition-normal), opacity 0.15s ease,
                    margin var(--transition-normal);
    }

    .sidebar:hover .theme-toggle-wrapper {
        max-height: 60px;
        opacity: 1;
        margin-bottom: var(--space-md);
    }

    /* Center icons when collapsed */
    .sidebar-link {
        justify-content: center;
    }

    .sidebar:hover .sidebar-link {
        justify-content: flex-start;
    }

    /* Center footer and avatar when collapsed */
    .sidebar-footer {
        padding: var(--space-sm) 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        transition: padding var(--transition-normal);
    }

    .sidebar:hover .sidebar-footer {
        padding: var(--space-md);
        align-items: stretch;
    }

    .sidebar-user {
        justify-content: center;
        gap: 0;
        padding: var(--space-sm) 0;
    }

    .sidebar:hover .sidebar-user {
        justify-content: flex-start;
        gap: var(--space-md);
        padding: var(--space-sm);
    }

    /* Collapsed active state: compact highlight behind icon only */
    .sidebar-link.active {
        background: transparent;
    }

    .sidebar-link.active .sidebar-link-icon {
        background: var(--color-primary-dim);
        border-radius: var(--radius-md);
        width: 32px;
        height: 32px;
        padding: 2px;
        color: var(--color-primary);
        opacity: 1;
    }

    /* Expanded: restore full-width background, reset icon */
    .sidebar:hover .sidebar-link.active {
        background: var(--color-primary-dim);
    }

    .sidebar:hover .sidebar-link.active .sidebar-link-icon {
        background: transparent;
        width: 20px;
        height: 20px;
        padding: 0;
    }

    /* Hide active indicator when collapsed */
    .sidebar-link.active::before {
        opacity: 0;
        transition: opacity var(--transition-normal);
    }

    .sidebar:hover .sidebar-link.active::before {
        opacity: 1;
    }
}

/* Mobile Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .header {
        padding-left: var(--space-md);
    }

    .mobile-menu-btn {
        display: flex;
    }

    .mobile-logout-btn {
        display: flex !important;
    }
}

@media (max-width: 768px) {
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: var(--space-md);
    }

    .page-actions {
        width: 100%;
    }

    .page-actions .btn {
        flex: 1;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .pedido-item-row {
        grid-template-columns: 1fr;
        gap: var(--space-sm);
    }

    .table {
        font-size: 13px;
    }

    .table th,
    .table td {
        padding: 8px 12px;
    }
}

/* Print Styles */
@media print {
    .sidebar,
    .header,
    .page-actions,
    .btn,
    .modal-overlay {
        display: none !important;
    }

    .main-content {
        margin-left: 0;
    }

    .page-content {
        padding: 0;
    }

    body {
        background: white;
        color: black;
    }

    .card {
        border: 1px solid #ddd;
        box-shadow: none;
    }
}

/* Encomenda Item Selection */
.encomenda-select-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-sm) var(--space-md);
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    border-bottom: none;
}

.encomenda-checkbox-label {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-secondary);
}

.encomenda-checkbox-label:hover {
    color: var(--text-primary);
}

.encomenda-select-actions + .table {
    border-radius: 0 0 var(--radius-md) var(--radius-md);
}

.row-low-stock {
    background: rgba(234, 179, 8, 0.08);
}

.row-low-stock:hover {
    background: rgba(234, 179, 8, 0.14);
}

tr:not(.row-low-stock) input[disabled],
tr:not(.row-low-stock) select[disabled],
.row-low-stock input[disabled],
.row-low-stock select[disabled] {
    opacity: 0.4;
}

/* Utility Classes */
.hidden {
    display: none !important;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-success {
    color: var(--color-success);
}

.text-warning {
    color: var(--color-warning);
}

.text-error {
    color: var(--color-error);
}

.text-muted {
    color: var(--text-secondary);
}

.mb-0 { margin-bottom: 0; }
.mb-1 { margin-bottom: var(--space-sm); }
.mb-2 { margin-bottom: var(--space-md); }
.mb-3 { margin-bottom: var(--space-lg); }
.mb-4 { margin-bottom: var(--space-xl); }

.mt-0 { margin-top: 0; }
.mt-1 { margin-top: var(--space-sm); }
.mt-2 { margin-top: var(--space-md); }
.mt-3 { margin-top: var(--space-lg); }

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: var(--space-sm); }
.gap-2 { gap: var(--space-md); }
.gap-3 { gap: var(--space-lg); }

/* ─── Perfil Page ───────────────────────────────────────────────── */
.perfil-avatar-wrap {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
    background: linear-gradient(135deg, var(--color-primary), var(--color-primary-hover));
    display: flex;
    align-items: center;
    justify-content: center;
}

.perfil-avatar-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.perfil-avatar-initials {
    font-size: 2rem;
    font-weight: 700;
    color: #0C0E0B;
    line-height: 1;
}

/* Make sidebar user behave as a link */
a.sidebar-user {
    color: inherit;
}
a.sidebar-user:hover {
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}
