:root {
    --bg-color: #f8f6ff;
    --card-bg: #ffffff;
    --primary-color: #c39efd;
    /* Lilás do logo */
    --primary-hover: #b089f0;
    --secondary-color: #ff8dc7;
    /* Rosa do logo */
    --text-color: #4a3a6e;
    /* Roxo escuro para texto */
    --text-muted: #8e82a8;
    --border-color: #e6e0f3;
    --success-color: #69f0ff;
    /* Ciano do logo para sucesso/info */
    --danger-color: #ff6b6b;
    --accent-yellow: #ffeb3b;
    /* Amarelo do logo */
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    margin: 0;
    padding: 0;
    line-height: 1.6;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

@media (max-width: 768px) {
    .container {
        padding: 16px;
    }
}

/* Header */
header {
    background-color: rgba(255, 255, 255, 0.86);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(0, 0, 0, 0.1);
    padding: 0.2rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

@media (max-width: 1000px) {
    .header-content {
        gap: 8px;
        padding-bottom: 0.2rem;
        flex-direction: column;
        /* Stack logo and nav for better space */
        align-items: stretch;
    }

    nav {
        max-width: 100%;
        justify-content: flex-start;
        /* Fixes cutoff issue */
        overflow-x: auto;
        padding-bottom: 5px;
        /* Space for scrollbar */
    }

    .logo {
        text-align: center;
        display: flex;
        justify-content: center;
    }

    .logo img {
        height: 45px !important;
    }
}

.logo {
    font-size: 1.75rem;
    font-weight: 800;
    color: var(--primary-color);
    text-decoration: none;
    letter-spacing: -0.025em;
}

nav {
    display: flex;
    flex-wrap: nowrap;
    justify-content: flex-start;
    /* Changed from flex-end to prevent left cutoff */
    gap: 2px;
    padding: 2px 0;
    max-width: 100%;
    /* Allow full width */
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

nav a {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    transition: all 0.2s ease;
    font-size: 0.75rem;
    white-space: nowrap;
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 3px;
}

nav a:hover {
    background-color: rgba(195, 158, 253, 0.1);
    color: var(--primary-color);
}

nav a.active {
    background-color: var(--primary-color);
    color: white;
}

@media (max-width: 768px) {
    nav {
        justify-content: center;
        padding-bottom: 5px;
    }

    nav a {
        padding: 8px 10px;
        font-size: 0.8rem;
    }
}

/* Buttons - Responsive sizing */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.75rem 1.5rem;
    background-color: var(--primary-color);
    color: white;
    text-decoration: none;
    border-radius: 12px;
    font-weight: 700;
    font-size: 1rem;
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 4px 6px -1px rgba(195, 158, 253, 0.3);
}

@media (max-width: 768px) {
    .btn {
        padding: 0.85rem 1.25rem;
        font-size: 0.95rem;
        width: 100%;
        /* Full width buttons on mobile usually feel better */
    }
}

.btn:hover {
    background-color: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(195, 158, 253, 0.4);
}

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

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

/* Responsive Venda Layout */
.venda-layout {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: start;
}

@media (min-width: 992px) {
    .venda-layout {
        display: grid;
        grid-template-columns: 1fr 1.5fr;
        gap: 2rem;
    }
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Cards */
.card {
    background-color: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    padding: 2.5rem;
    margin-bottom: 2.5rem;
}

@media (max-width: 768px) {
    .card {
        padding: 1.5rem;
    }
}

h1 {
    font-size: 2.5rem;
    margin-bottom: 0.5rem;
}

h2 {
    font-size: 1.8rem;
    margin-bottom: 1.5rem;
}

h3 {
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

/* Dashboard */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 2.5rem;
    margin-top: 2.5rem;
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }
}

.dashboard-card {
    background: var(--card-bg);
    padding: 2.5rem;
    border-radius: 12px;
    text-align: center;
    border: 2px solid var(--border-color);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100%;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .dashboard-card {
        padding: 1.5rem;
    }
}

.dashboard-card:hover {
    border-color: var(--primary-color);
    transform: scale(1.02);
    box-shadow: 0 12px 20px -5px rgba(0, 0, 0, 0.1);
}

@media (max-width: 768px) {
    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr);
        /* 2 columns on mobile if possible */
        gap: 12px;
    }

    .dashboard-icon {
        font-size: 2.5rem;
        margin-bottom: 0.75rem;
    }

    .dashboard-card {
        padding: 1.25rem !important;
    }

    .dashboard-card h3 {
        font-size: 0.9rem !important;
    }
}

/* Small mobile devices */
@media (max-width: 480px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

/* Forms */
input[type="text"],
input[type="number"],
textarea,
select {
    width: 100%;
    padding: 1rem;
    border: 2px solid var(--border-color);
    border-radius: 10px;
    font-size: 1.1rem;
    margin-top: 0.5rem;
    box-sizing: border-box;
}

input:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.1);
}

/* Tables */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

th {
    background-color: #f8fafc;
    padding: 1.25rem 1rem;
    border-bottom: 2px solid var(--border-color);
    font-weight: 700;
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border-color);
}

/* Responsive Table into Cards */
@media (max-width: 768px) {

    table,
    thead,
    tbody,
    th,
    td,
    tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        border: 2px solid var(--border-color);
        margin-bottom: 1rem;
        border-radius: 10px;
        background: white;
    }

    td {
        border: none;
        border-bottom: 1px solid #eee;
        position: relative;
        padding-left: 50%;
        text-align: right;
    }

    /* Labels dinâmicos via data-label para evitar hardcode no CSS */
    td:before {
        content: attr(data-label);
        position: absolute;
        left: 1rem;
        width: 45%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
    }
}

/* Alerts */
.alert {
    padding: 1.25rem;
    border-radius: 10px;
    margin-bottom: 2rem;
    font-weight: 600;
    border-left: 5px solid transparent;
}

.alert-success {
    background-color: #dcfce7;
    color: #166534;
    border-left-color: #22c55e;
}

.alert-error {
    background-color: #fee2e2;
    color: #991b1b;
    border-left-color: #ef4444;
}

/* Search Bar (New) */
.search-container {
    margin-bottom: 1.5rem;
    position: relative;
}

.search-input {
    padding-left: 3rem !important;
}

.search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2rem;
    color: var(--text-muted);
}

@media (max-width: 480px) {
    .card {
        padding: 1.25rem;
    }

    h1 {
        font-size: 1.8rem;
    }

    .btn {
        padding: 1rem;
    }
}