:root {
    --primary: #B7D906; /* Inspired by the yellow/green in the flowchart */
    --primary-hover: #a1c005;
    --primary-transparent: rgba(183, 217, 6, 0.15);
    
    --bg-color: #f8fafc;
    --bg-dark: #0f172a;
    --bg-darker: #020617;
    
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    
    --text-main: #1e293b;
    --text-muted: #64748b;
    --text-inverse: #f8fafc;
    
    --danger: #ef4444;
    --success: #22c55e;
    --warning: #f59e0b;
    --info: #3b82f6;

    --sidebar-width: 260px;
    --header-height: 80px;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;

    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

/* 
===========================================
    GENERIC COMPONENTS & UTILITIES 
=========================================== 
*/
a { text-decoration: none; color: inherit; }
button { cursor: pointer; font-family: inherit; }

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.95rem;
    border: none;
    transition: var(--transition);
}

.btn-primary {
    background-color: var(--primary);
    color: var(--bg-darker);
}
.btn-primary:hover {
    background-color: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px var(--primary-transparent);
}

.btn-outline {
    background-color: transparent;
    border: 1px solid var(--text-muted);
    color: var(--text-main);
}
.btn-outline:hover {
    border-color: var(--bg-dark);
    color: var(--bg-dark);
    background-color: var(--bg-color);
}

.btn-dark {
    background-color: var(--bg-dark);
    color: white;
}
.btn-dark:hover {
    background-color: var(--bg-darker);
    transform: translateY(-1px);
}

.btn-text {
    background: transparent;
    color: var(--text-muted);
    padding: 8px;
}
.btn-text:hover {
    color: var(--text-main);
    background: rgba(0,0,0,0.05);
}

.icon-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: white;
    border: 1px solid var(--card-border);
    color: var(--text-muted);
    transition: var(--transition);
    font-size: 1rem;
}
.icon-btn:hover {
    color: var(--text-main);
    border-color: var(--text-muted);
    box-shadow: var(--shadow-sm);
}

.card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}
.card.premium-glass {
    backdrop-filter: blur(16px);
    background: var(--glass-bg);
    border: 1px solid var(--glass-border);
    box-shadow: var(--shadow-md);
}

.form-group {
    margin-bottom: 20px;
}
.form-label {
    display: block;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-main);
}
.form-control {
    width: 100%;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: 1px solid var(--card-border);
    background: white;
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    transition: var(--transition);
}
.form-control:focus {
    outline: none;
    border-color: var(--bg-dark);
    box-shadow: 0 0 0 3px rgba(15, 23, 42, 0.1);
}
.form-control::placeholder {
    color: #94a3b8;
}
select.form-control {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 36px;
}

.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 12px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.badge-warning { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); }
.badge-success { background: rgba(34, 197, 94, 0.1); color: var(--success); border: 1px solid rgba(34, 197, 94, 0.2); }
.badge-info { background: rgba(59, 130, 246, 0.1); color: var(--info); border: 1px solid rgba(59, 130, 246, 0.2); }
.badge-neutral { background: rgba(100, 116, 139, 0.1); color: var(--text-muted); border: 1px solid rgba(100, 116, 139, 0.2); }

/* 
===========================================
    LAYOUT 
=========================================== 
*/
.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-dark);
    color: var(--text-inverse);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
}
.sidebar-header {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid rgba(255,255,255,0.05);
}
.sidebar-header .logo {
    height: 40px;
    object-fit: contain;
}
.sidebar-nav {
    flex: 1;
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    color: #94a3b8;
    font-weight: 500;
    transition: var(--transition);
}
.nav-item:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}
.nav-item.active {
    background: var(--primary);
    color: var(--bg-darker);
    font-weight: 600;
}
.sidebar-footer {
    padding: 24px 16px;
    border-top: 1px solid rgba(255,255,255,0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}
.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
}
.user-details {
    display: flex;
    flex-direction: column;
}
.user-name {
    font-size: 0.85rem;
    font-weight: 600;
}
.user-cnpj {
    font-size: 0.75rem;
    color: #94a3b8;
}
.logout-btn {
    color: #94a3b8;
    padding: 8px;
    border-radius: var(--radius-md);
    transition: var(--transition);
}
.logout-btn:hover {
    background: rgba(255,255,255,0.05);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}
.top-header {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 40px;
    position: sticky;
    top: 0;
    z-index: 90;
}
.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}
.page-subtitle {
    font-size: 0.9rem;
    color: var(--text-muted);
}
.content-container {
    padding: 40px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.flash-container {
    padding: 20px 40px 0;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.alert {
    padding: 16px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
    animation: slideInDown 0.3s ease;
}
.alert-error { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.alert-success { background: #dcfce3; color: #166534; border: 1px solid #86efac; }
.close-alert {
    background: transparent;
    border: none;
    color: inherit;
    opacity: 0.7;
    cursor: pointer;
}
.close-alert:hover { opacity: 1; }

@keyframes slideInDown {
    from { transform: translateY(-10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

/* 
===========================================
    LOGIN PAGE 
=========================================== 
*/
.login-body {
    background: var(--bg-color);
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100vh;
    position: relative;
    overflow: hidden;
}

/* Background decorations */
.login-body::before {
    content: '';
    position: absolute;
    top: -20vh;
    right: -10vw;
    width: 60vw;
    height: 60vw;
    border-radius: 50%;
    background: radial-gradient(circle, var(--primary-transparent) 0%, transparent 70%);
    z-index: 0;
}
.login-body::after {
    content: '';
    position: absolute;
    bottom: -20vh;
    left: -10vw;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(15, 23, 42, 0.05) 0%, transparent 70%);
    z-index: 0;
}

.login-wrapper {
    position: relative;
    z-index: 10;
    width: 100%;
    max-width: 480px;
    padding: 0 20px;
}
.login-logo {
    text-align: center;
    margin-bottom: 40px;
}
.login-logo img {
    height: 60px;
    object-fit: contain;
}
.login-card {
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(20px);
    border: 1px solid rgba(255, 255, 255, 0.6);
    box-shadow: 0 20px 40px rgba(0,0,0,0.08);
    border-radius: var(--radius-lg);
    padding: 40px;
}
.login-header {
    text-align: center;
    margin-bottom: 30px;
}
.login-header h2 {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--bg-dark);
    margin-bottom: 8px;
    letter-spacing: -0.5px;
}
.login-header p {
    color: var(--text-muted);
    font-size: 0.95rem;
}
.login-btn {
    width: 100%;
    padding: 14px;
    font-size: 1rem;
    margin-top: 10px;
}

/* Hamburger button — hidden on desktop */
.hamburger-btn {
    display: none;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
}
.hamburger-btn:hover {
    background: rgba(0,0,0,0.05);
}

/* Sidebar overlay — hidden on desktop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}
.sidebar-overlay.active {
    opacity: 1;
}

/*
===========================================
    RESPONSIVE — Tablet (max-width: 1024px)
===========================================
*/
@media (max-width: 1024px) {
    .content-container {
        padding: 28px 24px;
    }
    .top-header {
        padding: 0 24px;
    }
    .flash-container {
        padding: 16px 24px 0;
    }
}

/*
===========================================
    RESPONSIVE — Mobile (max-width: 768px)
===========================================
*/
@media (max-width: 768px) {
    /* Sidebar — off-canvas */
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
    }
    .sidebar.open {
        transform: translateX(0);
    }

    /* Overlay — visible when sidebar open */
    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }
    .sidebar-overlay.active {
        pointer-events: auto;
    }

    /* Main content — full width */
    .main-content {
        margin-left: 0;
    }

    /* Header */
    .top-header {
        padding: 0 16px;
        height: 64px;
        gap: 12px;
    }
    .page-title {
        font-size: 1.15rem;
    }
    .page-subtitle {
        font-size: 0.8rem;
    }

    /* Show hamburger */
    .hamburger-btn {
        display: flex;
    }

    /* Content */
    .content-container {
        padding: 20px 16px;
    }
    .flash-container {
        padding: 12px 16px 0;
    }

    /* Touch-friendly form controls */
    .form-control {
        min-height: 48px;
        font-size: 16px; /* Prevents iOS auto-zoom */
    }
    select.form-control {
        min-height: 48px;
    }
    /* Address form rows — stack on mobile */
    .form-group[style*="flex: 0 0"] {
        flex: 1 1 100% !important;
    }
    .btn {
        min-height: 44px;
        font-size: 0.9rem;
    }

    /* Cards — less padding on mobile */
    .card {
        padding: 16px;
    }

    /* Login page adjustments */
    .login-wrapper {
        padding: 0 16px;
    }
    .login-card {
        padding: 24px 20px;
    }
    .login-header h2 {
        font-size: 1.4rem;
    }
    .login-logo {
        margin-bottom: 24px;
    }
    .login-logo img {
        height: 48px;
    }
    .login-btn {
        min-height: 48px;
    }
}

/* Safari mobile fixes */
.login-btn {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

input[type="text"],
input[type="password"] {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    font-size: 16px; /* Prevents iOS auto-zoom */
}
