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

:root {
    --primary: #dc2626;
    --primary-hover: #b91c1c;
    --bg-main: #f9fafb;
    --bg-card: #ffffff;
    --sidebar-bg: #ffffff;
    --text-main: #111827;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --radius: 10px;
    --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    -webkit-font-smoothing: antialiased;
    letter-spacing: -0.01em;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar SaaS Style */
.sidebar {
    width: 260px;
    background-color: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    padding: 1.5rem 0;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 0 1.5rem 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.sidebar-header h2 {
    color: var(--primary);
    font-size: 1.5rem;
    font-weight: 800;
    letter-spacing: -0.05em;
    border: none;
    margin: 0;
}

.sidebar-header span {
    font-size: 0.7rem;
    color: var(--text-muted);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 0.75rem;
}

.nav-link {
    text-decoration: none;
    color: #4b5563;
    font-weight: 500;
    padding: 0.75rem 1rem;
    border-radius: 8px;
    transition: all 0.2s;
    font-size: 0.925rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.nav-link:hover {
    background-color: #f3f4f6;
    color: var(--text-main);
}

.nav-link.active {
    background-color: #fef2f2;
    color: var(--primary);
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2.5rem;
    overflow-y: auto;
}

.page-header {
    margin-bottom: 2.5rem;
}

.page-header h1 {
    font-size: 1.875rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.page-header p {
    color: var(--text-muted);
    font-size: 1rem;
}

.card {
    background: var(--bg-card);
    border-radius: var(--radius);
    padding: 1.5rem;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 2rem;
}

h2 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.25rem;
}

/* Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

/* Dynamic Items Section Redesign */
.card-inner {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 12px;
    margin-bottom: 1rem;
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.item-row-grid {
    display: grid;
    grid-template-columns: 1.5fr 90px 2fr 130px auto;
    gap: 1rem;
    align-items: flex-end;
}

.no-margin {
    margin-bottom: 0 !important;
}

.unit-label {
    position: absolute;
    right: 10px;
    font-size: 0.75rem;
    color: var(--text-muted);
    background: #f3f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    pointer-events: none;
}

.file-upload-wrapper {
    position: relative;
}

.item-photo {
    position: absolute;
    width: 0.1px;
    height: 0.1px;
    opacity: 0;
    overflow: hidden;
    z-index: -1;
}

.file-upload-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    border-style: dashed !important;
}

.action-cell {
    display: flex;
    align-items: flex-end;
    padding-bottom: 2px;
}

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

    .action-cell {
        justify-content: flex-end;
    }
}

.message {
    padding: 1rem;
    border-radius: var(--radius);
    font-size: 0.9rem;
    font-weight: 500;
    margin-top: 1rem;
    display: none;
}

.message.success {
    background-color: #dcfce7;
    color: #166534;
    display: block;
}

.message.error {
    background-color: #fee2e2;
    color: #991b1b;
    display: block;
}

.stat-card {
    background: white;
    padding: 1.5rem;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
}

.stat-title {
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
    margin-bottom: 0.5rem;
    display: block;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Forms */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.25rem;
}

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.4rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: #374151;
}

input,
textarea,
select {
    width: 100%;
    padding: 0.625rem 0.875rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-main);
    background-color: #fff;
    transition: border-color 0.15s ease;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.625rem 1.25rem;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.15s ease;
    gap: 8px;
    border: 1px solid transparent;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

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

.btn-outline {
    background-color: white;
    color: #374151;
    border: 1px solid var(--border);
}

.btn-outline:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
}

.btn-danger {
    background-color: #fee2e2;
    color: #b91c1c;
}

.btn-danger:hover {
    background-color: #fecaca;
}

.btn-process {
    background-color: #dbeafe;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.btn-process:hover {
    background-color: #bfdbfe;
    color: #1e3a8a;
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
}

/* Tables */
.table-container {
    border-radius: 8px;
    overflow-x: auto;
    border: 1px solid var(--border);
}

table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

th {
    background: #f9fafb;
    padding: 0.75rem 1rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    color: #4b5563;
    border-bottom: 1px solid var(--border);
}

td {
    padding: 1rem;
    border-bottom: 1px solid var(--border);
    font-size: 0.9rem;
}

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

tr:hover td {
    background-color: #fdfdfd;
}

/* Status Badges */
.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pendiente {
    background-color: #fef3c7;
    color: #92400e;
}

.status-aprobado {
    background-color: #dcfce7;
    color: #166534;
}

.status-rechazado {
    background-color: #fee2e2;
    color: #991b1b;
}

.status-en-proceso {
    background-color: #dbeafe;
    color: #1e40af;
}

.status-completado {
    background-color: #f3f4f6;
    color: #374151;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(2px);
}

.modal-content {
    background: white;
    margin: 3rem auto;
    padding: 2rem;
    border-radius: 12px;
    width: 95%;
    max-width: 1000px;
    box-shadow: var(--shadow-lg);
    position: relative;
}

.close-btn {
    position: absolute;
    right: 1.5rem;
    top: 1.5rem;
    font-size: 1.5rem;
    color: #9ca3af;
    cursor: pointer;
}

.close-btn:hover {
    color: #4b5563;
}

.modal-header {
    margin-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
    padding-bottom: 1rem;
}

.modal-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    background: #f9fafb;
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
}

.modal-meta p {
    font-size: 0.85rem;
}

.modal-meta strong {
    color: #6b7280;
    font-size: 0.7rem;
    text-transform: uppercase;
    display: block;
    margin-bottom: 2px;
}

.thumbnail {
    width: 48px;
    height: 48px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    cursor: pointer;
}

.modal-footer {
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border);
    text-align: right;
}
/* Modal Styles for User Management */
.modal.active { display: flex !important; align-items: center; justify-content: center; }

/* Badge Styles for Roles */
.badge { padding: 4px 12px; border-radius: 20px; font-size: 0.75rem; font-weight: 600; display: inline-block; }

/* Countdown Styles */
.countdown-danger {
    color: #dc2626;
    font-weight: 700;
    background: #fee2e2;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

.countdown-normal {
    color: #166534;
    font-weight: 600;
    background: #dcfce7;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.85rem;
}

/* Modal Table Inputs */
.compras-table input, .compras-table select {
    padding: 4px 8px;
    font-size: 0.85rem;
}

#projectsTable {
    min-width: 1200px;
}
