/* ===== CSS VARIABLES ===== */
:root {
    --primary-green: #2e7b52;        
    --secondary-green: #4f9d69;    
    --highlight-yellow: #fff876;     
    --highlight-yellow-dark: #f9c74f;
    
    --bg-light: #e4e6e3;             
    --text-dark: #191919;
    --text-light: #404040;
    --text-price: #f11764;             
    --text-highlight: var(--primary-green);
    
    --card-bg: #98c58c;              
    --footer-bg: #469e6f;
    --border-color: #d2d6d2;
    
    --input-bg: #ffffff;
    --input-border: #c5cac5;
    --input-focus: var(--primary-green);
    
    --btn-primary-bg: var(--primary-green);
    --btn-primary-text: #fff;
    --btn-primary-hover: #5aa461;
    
    --btn-secondary-bg: var(--highlight-yellow);
    --btn-secondary-text: #2e2e2e;
    --btn-secondary-hover: var(--highlight-yellow-dark);
    
    --btn-danger-bg: #f28482;
    --btn-danger-hover: #e05e5c;
    
    --success: #90be6d;  
    --warning: #f9c74f;  
    --error: #f28482;
}

/* ===== DARK THEME ===== */
[data-theme="dark"] {
    --primary-green: #2e7b52;       
    --secondary-green: #4f9d69;     
    --highlight-yellow: #ffd670;     
    --highlight-yellow-dark: #f9c74f;
    
    --bg-light: #1c1c1c;          
    --text-dark: #ededed;
    --text-light: #c0c0c0;
    --text-highlight: var(--highlight-yellow);
    --card-bg: #262626;
    --footer-bg: rgb(59, 134, 82);
    --border-color: #3a3a3a;
    
    --input-bg: #2a2a2a;
    --input-border: #3a3a3a;
    --input-focus: var(--highlight-yellow);
    
    --btn-primary-bg: var(--primary-green);
    --btn-primary-text: #fff;
    --btn-primary-hover: #336a42;
    
    --btn-secondary-bg: var(--highlight-yellow);
    --btn-secondary-text: #1c1c1c;
    --btn-secondary-hover: var(--highlight-yellow-dark);
    
    --btn-danger-bg: #f28b82;
    --btn-danger-hover: #ff6b68;
    
    --success: #4f9d69;   
    --warning: #ffd670;
    --error: #f28b82;
}

/* ===== GLOBAL STYLES ===== */
@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@300;400;600;700&display=swap');

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

html {
    scroll-behavior: smooth;
}

body {
    font-family: 'Nunito', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    transition: background-color 0.3s ease, color 0.3s ease;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 1rem;
}

/* ===== HEADER ===== */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem;
    background: linear-gradient(135deg, var(--card-bg) 0%, rgba(152, 197, 140, 0.85) 100%);
    border-radius: 12px;
    margin-bottom: 2rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
}

header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: radial-gradient(circle at 20% 50%, rgba(255, 248, 118, 0.1) 0%, transparent 50%);
    pointer-events: none;
}

header a {
    position: relative;
    z-index: 1;
    transition: transform 0.3s ease;
}

header a:hover {
    transform: scale(1.05);
}

header img {
    width: 120px;
    height: auto;
    display: block;
}

/* ===== MAIN CONTENT ===== */
main {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    flex: 1;
    animation: slideIn 0.4s ease;
}

main > h1 {
    font-size: 1.8rem;
    color: var(--text-dark);
    font-weight: 700;
    margin-bottom: 1.5rem;
    text-align: center;
    position: relative;
    padding-bottom: 1rem;
}

main > h1::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 80px;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-green), var(--highlight-yellow));
    border-radius: 2px;
}

/* ===== ERROR MESSAGE ===== */
.error-message {
    background: linear-gradient(135deg, var(--error) 0%, #ff6b6b 100%);
    color: #fff;
    padding: 2rem;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 8px 24px rgba(242, 132, 130, 0.3);
    margin: 2rem auto;
    max-width: 600px;
    animation: fadeIn 0.4s ease;
}

.error-message h1 {
    font-size: 1.5rem;
    font-weight: 700;
}

/* ===== TABLE CONTAINER ===== */
.table-wrapper {
    background-color: var(--card-bg);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
    overflow-x: auto;
    animation: slideIn 0.4s ease;
}

/* ===== TABLE STYLES ===== */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: var(--input-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

thead {
    background: linear-gradient(135deg, var(--primary-green) 0%, var(--secondary-green) 100%);
}

thead tr th {
    padding: 1rem 0.8rem;
    text-align: left;
    font-weight: 700;
    font-size: 0.9rem;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

tbody tr {
    border-bottom: 1px solid var(--border-color);
    transition: all 0.3s ease;
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr:hover {
    background-color: rgba(152, 197, 140, 0.15);
    transform: scale(1.01);
}

tbody tr td {
    padding: 1rem 0.8rem;
    font-size: 0.9rem;
    color: var(--text-dark);
    vertical-align: middle;
}

/* ===== TABLE CELLS SPECIFIC ===== */
tbody tr td:first-child {
    font-weight: 700;
    color: var(--primary-green);
}

tbody tr td:nth-child(5) {
    font-weight: 600;
}

/* Admin badge */
tbody tr td:nth-child(5):has-text("Sim") {
    color: var(--success);
}

/* ===== ACTION BUTTONS ===== */
tbody tr td:last-child {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

tbody tr td a {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
    font-weight: 600;
    font-family: 'Nunito', sans-serif;
    text-decoration: none;
    border-radius: 8px;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    white-space: nowrap;
}

/* Edit button */
tbody tr td a[href*="form-editarUsuario"] {
    background: linear-gradient(135deg, var(--btn-primary-bg) 0%, var(--btn-primary-hover) 100%);
    color: var(--btn-primary-text);
    border: none;
}

tbody tr td a[href*="form-editarUsuario"]:hover {
    background: linear-gradient(135deg, var(--btn-primary-hover) 0%, var(--primary-green) 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(46, 123, 82, 0.3);
}

/* Delete button */
tbody tr td a[href*="action-deletarUsuario"] {
    background: linear-gradient(135deg, var(--btn-danger-bg) 0%, var(--btn-danger-hover) 100%);
    color: #fff;
    border: none;
}

tbody tr td a[href*="action-deletarUsuario"]:hover {
    background: linear-gradient(135deg, var(--btn-danger-hover) 0%, #d44442 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(242, 132, 130, 0.3);
}

/* ===== EMPTY STATE ===== */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: var(--text-light);
}

.empty-state i {
    font-size: 4rem;
    color: var(--primary-green);
    opacity: 0.3;
    margin-bottom: 1rem;
}

.empty-state p {
    font-size: 1.1rem;
    font-weight: 600;
}

/* ===== ANIMATIONS ===== */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== RESPONSIVE - MOBILE ADJUSTMENTS ===== */
@media (max-width: 767px) {
    body {
        padding: 0.5rem;
    }

    header {
        padding: 0.8rem;
        margin-bottom: 1rem;
    }

    header img {
        width: 100px;
    }

    main > h1 {
        font-size: 1.5rem;
        margin-bottom: 1rem;
    }

    .table-wrapper {
        padding: 1rem;
        border-radius: 12px;
    }

    /* Stack table for mobile */
    table, thead, tbody, th, td, tr {
        display: block;
    }

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

    tbody tr {
        margin-bottom: 1rem;
        border: 2px solid var(--border-color);
        border-radius: 12px;
        padding: 1rem;
        background-color: var(--input-bg);
    }

    tbody tr:hover {
        transform: scale(1);
    }

    tbody tr td {
        border: none;
        position: relative;
        padding: 0.8rem 0.5rem;
        padding-left: 45%;
        text-align: right;
    }

    tbody tr td::before {
        content: attr(data-label);
        position: absolute;
        left: 0.5rem;
        width: 40%;
        padding-right: 0.5rem;
        white-space: nowrap;
        font-weight: 700;
        text-align: left;
        color: var(--primary-green);
    }

    tbody tr td:last-child {
        padding-left: 0.5rem;
        justify-content: flex-end;
        flex-direction: row;
    }

    tbody tr td:last-child::before {
        content: 'Ações:';
        position: relative;
        width: auto;
        display: block;
        margin-bottom: 0.5rem;
        text-align: center;
    }

    tbody tr td a {
        flex: 1;
        justify-content: center;
        min-width: 100px;
    }
}

/* ===== RESPONSIVE - TABLET (768px+) ===== */
@media (min-width: 768px) {
    body {
        padding: 1.5rem;
    }

    header {
        padding: 1.5rem 2rem;
        margin-bottom: 2.5rem;
    }

    header img {
        width: 140px;
    }

    main > h1 {
        font-size: 2rem;
        margin-bottom: 2rem;
    }

    .table-wrapper {
        padding: 2rem;
    }

    thead tr th {
        padding: 1.2rem 1rem;
        font-size: 0.95rem;
    }

    tbody tr td {
        padding: 1.2rem 1rem;
        font-size: 0.95rem;
    }

    tbody tr td a {
        padding: 0.6rem 1.2rem;
        font-size: 0.9rem;
    }
}

/* ===== RESPONSIVE - DESKTOP (1024px+) ===== */
@media (min-width: 1024px) {
    body {
        padding: 2rem;
    }

    header {
        padding: 1.5rem 2.5rem;
    }

    header img {
        width: 150px;
    }

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

    .table-wrapper {
        padding: 2.5rem;
    }

    thead tr th {
        padding: 1.5rem 1.2rem;
        font-size: 1rem;
    }

    tbody tr td {
        padding: 1.5rem 1.2rem;
        font-size: 1rem;
    }

    tbody tr td a {
        padding: 0.7rem 1.5rem;
        font-size: 0.95rem;
    }
}

/* ===== ACCESSIBILITY ===== */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 3px solid var(--primary-green);
    outline-offset: 2px;
}

[data-theme="dark"] *:focus-visible {
    outline-color: var(--highlight-yellow);
}

/* ===== PRINT STYLES ===== */
@media print {
    body {
        background: #fff;
        color: #000;
    }

    header, .table-wrapper {
        box-shadow: none;
    }

    tbody tr td a {
        display: none;
    }
}