:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-accent: rgba(99, 102, 241, 0.1);
    --secondary: #64748b;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #3b82f6;
    --bg: #f8fafc;
    --card-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-xl: 30px;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 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);
    --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);
}

.badge {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: bold;
    text-transform: uppercase;
}
.badge-primary { background: var(--primary); color: white; }
.badge-secondary { background: var(--secondary); color: white; }

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text-main);
    line-height: 1.5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

header {
    background: linear-gradient(90deg, #8b5cf6 0%, #6366f1 100%);
    color: white;
    padding: 20px 40px;
    border-radius: var(--radius-md);
    margin: 0 0 30px 0;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.2);
    position: relative;
    overflow: hidden;
}

header::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 300px;
    height: 300px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    gap: 20px;
    position: relative;
    z-index: 1;
}

.header-brand {
    text-align: left;
}

header h1 {
    font-size: 32px;
    margin-bottom: 5px;
    font-weight: 800;
    letter-spacing: -1px;
}

header p {
    opacity: 0.9;
    font-size: 14px;
}

.user-info-badge {
    display: flex;
    align-items: center;
    gap: 15px;
    background: rgba(255, 255, 255, 0.15);
    padding: 8px 16px;
    border-radius: var(--radius-xl);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    box-shadow: var(--shadow-sm);
}

.user-details {
    text-align: right;
}

.user-name {
    font-weight: 700;
    font-size: 14px;
    line-height: 1.2;
}

.user-role {
    font-size: 10px;
    opacity: 0.8;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.logout-btn {
    background: var(--danger);
    border: none;
    padding: 6px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    font-size: 14px;
}

.logout-btn:hover {
    transform: scale(1.1);
    filter: brightness(1.1);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.4);
}

.nav {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-bottom: 30px;
    padding: 5px 0;
}

.nav button {
    padding: 8px 16px;
    border: none;
    border-radius: 100px;
    background: var(--card-bg);
    color: var(--secondary);
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-size: 12px;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.03);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 6px;
    border: 1px solid rgba(0, 0, 0, 0.03);
}

.nav button:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    color: var(--primary);
    background: #fefeff;
}

.nav button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.3);
    border-color: transparent;
}

/* Sub-tabs styles */
.sub-nav {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
    padding: 10px;
    background: rgba(0, 0, 0, 0.03);
    border-radius: var(--radius-md);
}

.sub-nav button {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--secondary);
    font-weight: 600;
    cursor: pointer;
    font-size: 14px;
    border-radius: 100px;
    transition: all 0.2s;
}

.sub-nav button:hover {
    background: rgba(0, 0, 0, 0.05);
    color: var(--primary);
}

.sub-nav button.active {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 6px rgba(99, 102, 241, 0.2);
}

.sub-tab-content {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(5px); }
    to { opacity: 1; transform: translateY(0); }
}

.content {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.card-stat {
    position: relative;
    overflow: hidden;
    padding: 25px;
    display: flex;
    flex-direction: column;
}

.card-stat .icon {
    position: absolute;
    right: 20px;
    top: 20px;
    font-size: 40px;
    opacity: 0.15;
    transform: rotate(-10deg);
}

.card-stat .stat-label {
    text-transform: uppercase;
    font-size: 11px;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.card-stat .stat {
    font-size: 32px;
    font-weight: 800;
    color: var(--text-main);
}

.card-stat .stat-footer {
    margin-top: 15px;
    font-size: 12px;
    color: var(--text-muted);
}

/* Specific Card Variants */
.card-total-items {
    border-left: 5px solid var(--primary);
}

.card-total-volume {
    border-left: 5px solid #a855f7;
}

.card-low-stock {
    border-left: 5px solid var(--danger);
}

.card-transactions {
    border-left: 5px solid var(--success);
}

.card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-4px);
}

.card h3 {
    color: var(--text-main);
    margin-bottom: 20px;
    font-size: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}

.stat {
    font-size: 28px;
    font-weight: bold;
    color: #667eea;
    margin: 8px 0;
}

.stat-label {
    color: var(--text-muted);
    font-size: 13px;
}

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--card-bg);
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

table thead {
    background: #f1f5f9;
    color: var(--text-muted);
}

table th {
    font-weight: 700;
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: 0.1em;
    white-space: nowrap;
}

table th,
table td {
    padding: 16px;
    text-align: left;
    border-bottom: 1px solid #f1f5f9;
}

table tbody tr:last-child td {
    border-bottom: none;
}

table tbody tr:hover {
    background: #f8fafc;
}

.form-group {
    margin-bottom: 12px;
}

.align-left {
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 4px;
    font-weight: bold;
    color: #666;
    font-size: 13px;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e2e8f0;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 14px;
    transition: all 0.2s;
    background: #f8fafc;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(99, 102, 241, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

.form-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
}

.form-grid .form-group.full-width {
    grid-column: span 2;
}

@media (max-width: 600px) {
    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .form-group.full-width {
        grid-column: span 1;
    }
}

button[type="submit"] {
    background: var(--primary);
    color: white;
    padding: 14px 28px;
    font-size: 15px;
    border: none;
    border-radius: 100px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    width: 100%;
    box-shadow: 0 4px 6px -1px rgba(99, 102, 241, 0.4);
}

button[type="submit"]:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 10px 15px -3px rgba(99, 102, 241, 0.4);
}

.btn-danger {
    background: var(--danger);
    color: white;
    padding: 8px 16px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-danger:hover {
    filter: brightness(1.1);
    transform: scale(1.05);
}

.alert {
    padding: 15px;
    border-radius: 5px;
    margin-bottom: 15px;
}

.alert-info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

.alert-error {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.alert-success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.color-swatch {
    display: inline-block;
    width: 30px;
    height: 30px;
    border-radius: 5px;
    border: 1px solid #ddd;
}

.hidden {
    display: none;
}

.loading {
    text-align: center;
    padding: 20px;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }

    100% {
        transform: rotate(360deg);
    }
}

.empty {
    text-align: center;
    padding: 40px 20px;
    color: #999;
}

.empty-icon {
    font-size: 48px;
    margin-bottom: 10px;
}

@media print {
    body {
        background: white;
    }

    .nav,
    header {
        display: none;
    }

    .report-page {
        max-width: 297mm;
        height: 420mm;
        margin: 0;
        padding: 20mm;
        box-shadow: none;
    }
}

.report-page {
    background: white;
    padding: 15mm;
    margin: 0 auto;
    width: 297mm;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    font-size: 11px;
    line-height: 1.4;
}

.report-header {
    text-align: center;
    margin-bottom: 15px;
    border-bottom: 2px solid #333;
    padding-bottom: 10px;
}

.report-header h1 {
    font-size: 18px;
    margin: 0 0 5px 0;
}

.report-header p {
    margin: 2px 0;
    font-size: 10px;
    color: #666;
}

.report-section {
    margin-bottom: 15px;
}

.report-section h2 {
    font-size: 13px;
    background: #667eea;
    color: white;
    padding: 5px 10px;
    margin: 0 0 8px 0;
    border-radius: 3px;
}

.report-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10px;
    page-break-inside: avoid;
}

.report-table th {
    background: #f0f0f0;
    border: 1px solid #999;
    padding: 5px;
    text-align: left;
    font-weight: bold;
}

.report-table td {
    border: 1px solid #ccc;
    padding: 4px;
}

.report-table tbody tr:nth-child(even) {
    background: #f9f9f9;
}

.report-footer {
    margin-top: 20px;
    padding-top: 10px;
    border-top: 1px solid #999;
    text-align: center;
    font-size: 9px;
    color: #666;
}

.print-btn {
    background: var(--success);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-weight: 700;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    box-shadow: 0 4px 6px -1px rgba(16, 185, 129, 0.3);
}

.print-btn:hover {
    background: #764ba2;
}

.transactions-container {
    margin-top: 15px;
}

.transactions-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.transaction-item {
    background: #f8f9fa;
    padding: 15px;
    border-radius: var(--radius-md);
    border-left: 4px solid var(--primary);
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: all 0.2s;
    margin-bottom: 8px;
    box-shadow: var(--shadow-sm);
}

.dashboard-trans-grid {
    display: grid;
    grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
    gap: 15px;
    align-items: center;
    width: 100%;
}

.trans-main-info {
    display: flex;
    flex-direction: column;
}

.item-sub-info {
    font-size: 10px;
    color: var(--text-muted);
    margin-top: 2px;
}

.trans-type-badge {
    font-weight: 800;
    font-size: 10px;
    margin-top: 4px;
    text-transform: uppercase;
}

.trans-meta-item {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.meta-label {
    color: var(--text-muted);
    font-size: 10px;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 0.05em;
}

.meta-value {
    font-weight: 600;
    color: var(--text-main);
    font-size: 13px;
}

.meta-align-right {
    text-align: right;
}

@media (max-width: 900px) {
    .dashboard-trans-grid {
        grid-template-columns: 1fr 1fr;
        gap: 15px;
    }
    
    .meta-align-right {
        text-align: left;
    }
}

@media (max-width: 600px) {
    .dashboard-trans-grid {
        grid-template-columns: 1fr;
        gap: 10px;
    }
}

/* Search and Filters */
.filters-bar {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
    background: white;
    padding: 15px;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    flex-wrap: wrap;
    align-items: center;
}

.search-wrapper {
    position: relative;
    flex: 1;
    min-width: 250px;
}

.search-wrapper input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s;
}

.search-wrapper input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.search-wrapper i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #999;
}

.filter-select {
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 6px;
    min-width: 150px;
    font-size: 14px;
}

/* Toasts */
#toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.toast {
    min-width: 280px;
    background: white;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
    border-left: 5px solid #667eea;
    animation: toast-in 0.4s ease-out forwards;
    cursor: pointer;
}

@keyframes toast-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast.toast-out {
    animation: toast-out 0.4s ease-in forwards;
}

@keyframes toast-out {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

.toast-success {
    border-left-color: #10b981;
}

.toast-error {
    border-left-color: #ef4444;
}

.toast-info {
    border-left-color: #3b82f6;
}

.toast-message {
    font-size: 14px;
    font-weight: 500;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: flex-start; /* Permite rolar a partir do topo */
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
    overflow-y: auto; /* Habilita rolagem vertical */
    padding: 40px 20px; /* Espaço para não colar nas bordas */
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    width: 100%;
    max-width: 450px;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
    transform: translateY(20px);
    transition: all 0.3s;
    max-height: 90vh;
    overflow-y: auto;
}

#receive-items-list {
    max-height: 400px;
    overflow-y: auto;
    padding-right: 10px;
    margin-bottom: 20px;
    scrollbar-width: thin;
}

#receive-items-list::-webkit-scrollbar {
    width: 6px;
}

#receive-items-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 10px;
}

.modal-overlay.active .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 15px;
}

.modal-title {
    font-size: 18px;
    font-weight: bold;
    color: #333;
}

.modal-body {
    font-size: 15px;
    color: #666;
    margin-bottom: 25px;
    line-height: 1.5;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.modal-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.modal-btn-cancel {
    background: #f3f4f6;
    color: #4b5563;
}

.modal-btn-confirm {
    background: #667eea;
    color: white;
}

.modal-btn-confirm:hover {
    background: #764ba2;
}

.modal-btn-cancel:hover {
    background: #e5e7eb;
}

.login-modal {
    max-width: 400px;
    text-align: center;
}

.login-modal-icon {
    font-size: 50px;
    margin-bottom: 20px;
}

.login-modal-subtitle {
    color: var(--text-muted);
    margin-bottom: 25px;
}

.login-submit-btn {
    margin-top: 15px;
    background: var(--primary);
    color: white;
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-lg);
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
    box-shadow: 0 4px 15px var(--primary-accent);
}

.login-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px var(--primary-accent);
}

.error-text {
    color: var(--danger);
    margin-top: 15px;
    font-size: 13px;
    font-weight: 600;
}

/* Pagination */
.pagination-controls {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 15px 0;
    margin-top: 10px;
}

.pagination-controls button {
    padding: 6px 14px;
    border: none;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination-controls button:not(:disabled):hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

/* Secondary button */
.btn-secondary {
    background: var(--secondary);
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-secondary:hover {
    filter: brightness(1.1);
}

/* Close modal button */
.close-modal {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: #999;
    padding: 0 5px;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: #333;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .container {
        max-width: 100%;
    }
}

@media (max-width: 768px) {
    header {
        padding: 20px;
        margin-bottom: 20px;
    }

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 15px;
    }

    .user-info-badge {
        width: 100%;
        justify-content: space-between;
    }

    header h1 {
        font-size: 24px;
    }

    .filters-bar {
        flex-direction: column;
        align-items: stretch;
    }

    .search-wrapper {
        min-width: 100%;
    }

    .modal-content {
        max-width: 95%;
        padding: 20px;
    }

    .form-grid {
        grid-template-columns: 1fr;
    }

    .form-grid .form-group.full-width {
        grid-column: span 1;
    }
    
    .card {
        padding: 16px;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 12px;
    }

    header {
        padding: 15px;
        border-radius: var(--radius-sm);
    }

    header h1 {
        font-size: 20px;
    }

    header p {
        font-size: 12px;
    }

    .nav button {
        padding: 6px 10px;
        font-size: 11px;
    }

    .card-stat {
        padding: 15px;
    }

    .card-stat .stat {
        font-size: 24px;
    }

    .card-stat .icon {
        font-size: 30px;
    }
    
    .modal-footer {
        flex-direction: column;
    }
    
    .modal-btn {
        width: 100%;
    }
}

/* Fix for touch devices scroll bars */
@media (pointer: coarse) {
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }
}