/* ==============================================
   Sinorg - CSS Principal
   Layout: Sidebar + Conteúdo
   Responsivo: Mobile-first
   ============================================== */

/* --- Reset & Base --- */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #d97706;
    --info: #0891b2;
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-500: #6b7280;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;
    --sidebar-width: 250px;
    --sidebar-bg: #1e293b;
    --sidebar-text: #cbd5e1;
    --sidebar-active: #3b82f6;
    --border-radius: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 4px 12px rgba(0,0,0,0.15);
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: var(--font-family);
    background: var(--gray-100);
    color: var(--gray-800);
    min-height: 100vh;
}

/* --- App Container --- */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s ease;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    color: var(--sidebar-text);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0.25rem;
}

/* --- Sidebar Nav --- */
.sidebar-nav {
    list-style: none;
    flex: 1;
    overflow-y: auto;
    padding: 0.5rem 0;
}

.sidebar-group {
    padding: 0.75rem 1.25rem 0.25rem;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    font-weight: 600;
}

.sidebar-item a {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 1.25rem;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: background 0.2s, color 0.2s;
    border-left: 3px solid transparent;
}

.sidebar-item a:hover {
    background: rgba(255,255,255,0.05);
    color: #fff;
}

.sidebar-item.active a {
    background: rgba(59,130,246,0.15);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

/* --- Sidebar Overlay (Mobile) --- */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99;
}

/* --- Content --- */
.content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 2rem;
    min-height: 100vh;
}

.content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--gray-900);
    margin-bottom: 0.5rem;
}

.subtitle {
    color: var(--gray-500);
    margin-bottom: 1.5rem;
}

/* --- Login Wrapper (sem sidebar) --- */
.login-wrapper {
    margin-left: 0 !important;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    padding: 2rem;
}

.login-card {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 2.5rem;
    box-shadow: var(--shadow-lg);
    text-align: center;
    max-width: 400px;
    width: 100%;
}

.login-logo h1 {
    font-size: 2rem;
    color: var(--primary);
    margin-bottom: 0.5rem;
}

.login-subtitle {
    color: var(--gray-500);
    margin-bottom: 2rem;
    font-size: 0.9375rem;
}

.google-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1.5rem;
    background: #fff;
    border: 2px solid var(--gray-200);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--gray-700);
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.google-btn:hover {
    background: var(--gray-50);
    border-color: var(--gray-300);
    box-shadow: var(--shadow);
}

.google-btn-back {
    background: #666;
    color: #fff;
    border-color: #666;
}

.google-btn-back:hover {
    background: #555;
    border-color: #555;
}

.google-icon {
    flex-shrink: 0;
}

/* --- Dashboard Grid --- */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-top: 1.5rem;
}

/* --- Cards --- */
.card {
    background: #fff;
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--gray-200);
}

.card h3 {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--gray-500);
    text-transform: uppercase;
    letter-spacing: 0.025em;
    margin-bottom: 0.5rem;
}

.card .stat {
    font-size: 2rem;
    font-weight: 700;
    color: var(--gray-900);
}

.card-mb {
    margin-bottom: 1.5rem;
}

/* --- Tables --- */
.table-responsive {
    overflow-x: auto;
    margin-top: 1rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

.data-table thead {
    background: var(--gray-50);
}

.data-table th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--gray-500);
    border-bottom: 2px solid var(--gray-200);
}

.data-table td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--gray-100);
    font-size: 0.875rem;
    vertical-align: middle;
}

.data-table tbody tr:hover {
    background: var(--gray-50);
}

.row-blocked {
    background: #fef2f2 !important;
}

.row-highlight {
    background: #fef9c3;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.125rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    background: var(--gray-200);
    color: var(--gray-700);
}

.badge-active   { background: #dcfce7; color: #166534; }
.badge-inactive { background: #fee2e2; color: #991b1b; }
.badge-blocked  { background: #fee2e2; color: #991b1b; }
.badge-admin    { background: #dbeafe; color: #1e40af; }
.badge-user     { background: var(--gray-200); color: var(--gray-700); }
.badge-error    { background: #fee2e2; color: #991b1b; }
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-info     { background: #dbeafe; color: #1e40af; }

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border: none;
    border-radius: 6px;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
    background: var(--primary);
    color: #fff;
}

.btn:hover          { background: var(--primary-dark); }
.btn:active         { transform: scale(0.98); }
.btn-sm             { padding: 0.25rem 0.625rem; font-size: 0.75rem; }
.btn-success        { background: var(--success); }
.btn-success:hover  { background: #15803d; }
.btn-danger         { background: var(--danger); }
.btn-danger:hover   { background: #b91c1c; }
.btn-warning        { background: var(--warning); color: #fff; }
.btn-warning:hover  { background: #b45309; }
.btn-info           { background: var(--info); }
.btn-info:hover     { background: #0e7490; }
.btn-active         { background: var(--primary-dark); box-shadow: 0 0 0 2px var(--primary); }

/* --- Forms --- */
.inline-form {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.inline-form-gap {
    gap: 0.5rem;
}

.actions {
    display: flex;
    gap: 0.375rem;
    flex-wrap: wrap;
}

.input-sm {
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.8125rem;
    outline: none;
}

.input-sm:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.input-order {
    width: 60px;
    text-align: center;
}

/* --- CRUD inline form --- */
.edit-form-wrap {
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
}

.edit-form-hidden          { display: none; }
.edit-form-hidden.is-visible { display: flex; }

.edit-form-label {
    display: flex;
    flex-direction: column;
    gap: 0.125rem;
    font-size: 0.75rem;
    color: var(--gray-500);
}

.cell-empty {
    color: var(--gray-300);
}

.input-w-xs   { width: 5rem; }
.input-w-sm   { width: 6rem; }
.input-w-md   { width: 8rem; }
.input-w-rota { width: 10rem; }
.input-w-lg   { width: 12rem; }
.input-w-xl   { width: 14rem; }

/* --- Filter Form --- */
.filter-form {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: flex-end;
    margin-bottom: 1rem;
    padding: 1rem;
    background: #fff;
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.filter-group label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500);
}

.filter-group input,
.filter-group select {
    padding: 0.375rem 0.625rem;
    border: 1px solid var(--gray-300);
    border-radius: 4px;
    font-size: 0.8125rem;
    outline: none;
}

.filter-group input:focus,
.filter-group select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(37,99,235,0.2);
}

.result-count {
    font-size: 0.8125rem;
    color: var(--gray-500);
    margin-bottom: 0.5rem;
}

/* --- Pagination --- */
.pagination {
    display: flex;
    gap: 0.375rem;
    margin-top: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

/* --- Utilities --- */
.d-none      { display: none !important; }
.text-center { text-align: center; }

.truncate {
    max-width: 200px;
    display: inline-block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay.open {
        display: block;
    }

    .menu-toggle {
        display: block;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 101;
        background: var(--sidebar-bg);
        color: #fff;
        border-radius: 6px;
        padding: 0.5rem;
        box-shadow: var(--shadow);
    }

    .content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 3.5rem;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .filter-form {
        flex-direction: column;
        align-items: stretch;
    }

    .data-table {
        font-size: 0.8125rem;
    }

    .data-table th,
    .data-table td {
        padding: 0.5rem;
    }

    .actions {
        flex-direction: column;
    }
}

@media (max-width: 480px) {
    .login-card {
        padding: 1.5rem;
    }

    .card .stat {
        font-size: 1.5rem;
    }
}
