/**
 * Planeador Pautas - Main Stylesheet
 * Modern, Hootsuite-inspired design
 */

/* ===== CSS Variables ===== */
:root {
    --primary-color: #ff27c5;
    --primary-hover: #e01daf;
    --primary-light: rgba(255, 39, 197, 0.1);

    --secondary-color: #1a1a2e;
    --secondary-light: #2d2d44;
    --secondary-dark: #0f0f1a;

    --accent-color: #8a5aff;
    --accent-gradient: linear-gradient(135deg, #8a5aff 0%, #ff27c5 100%);

    --success-color: #06ace4;
    --warning-color: #ffc107;
    --error-color: #ff5252;
    --info-color: #06ace4;

    --bg-color: #f5f7f9;
    --bg-card: #ffffff;
    --bg-sidebar: #1a1a2e;

    --text-primary: #1a1a2e;
    --text-secondary: #64748b;
    --text-light: #94a3b8;
    --text-white: #ffffff;

    --border-color: #e2e8f0;
    --border-radius: 8px;
    --border-radius-lg: 12px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.07);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
    --shadow-xl: 0 20px 40px rgba(0, 0, 0, 0.15);

    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;

    --sidebar-width: 260px;
    --topbar-height: 70px;

    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s ease;
}

/* ===== Reset & Base ===== */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: 14px;
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

a {
    color: inherit;
    text-decoration: none;
}

button {
    font-family: inherit;
    cursor: pointer;
    border: none;
    background: none;
}

input,
select,
textarea {
    font-family: inherit;
    font-size: inherit;
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== Login Page ===== */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(145deg, #0f0f1a 0%, #1a1a2e 30%, #2d2044 60%, #1a1a2e 100%);
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 440px;
}

.login-card {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 48px 40px 36px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 40px rgba(138, 90, 255, 0.05);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo img {
    max-height: 200px;
    width: auto;
}

.login-card h1 {
    font-size: 1.25rem;
    font-weight: 500;
    text-align: center;
    margin-bottom: 28px;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon {
    position: absolute;
    left: 14px;
    width: 18px;
    height: 18px;
    color: var(--text-light);
    pointer-events: none;
    z-index: 1;
}

.form-group .input-icon-wrapper input {
    width: 100%;
    padding: 12px 16px 12px 44px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.95rem;
    transition: var(--transition-fast);
    background: #f8f9fb;
    color: var(--text-primary);
}

.form-group .input-icon-wrapper input::placeholder {
    color: var(--text-light);
}

.form-group .input-icon-wrapper input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    background: var(--bg-card);
}

/* Gradient Button */
.btn-gradient {
    background: linear-gradient(135deg, #ff27c5 0%, #8a5aff 50%, #06ace4 100%);
    color: white;
    border: none;
    padding: 12px 24px;
    font-size: 0.95rem;
    font-weight: 600;
    border-radius: var(--border-radius);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.3s ease;
    box-shadow: 0 4px 15px rgba(138, 90, 255, 0.3);
}

.btn-gradient:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(138, 90, 255, 0.4);
    filter: brightness(1.05);
}

.login-admin-link {
    text-align: center;
    margin-top: 24px;
    font-size: 0.85rem;
    color: var(--text-light);
}

.login-admin-link a {
    color: var(--accent-color);
    font-weight: 500;
    text-decoration: none;
    transition: var(--transition-fast);
}

.login-admin-link a:hover {
    color: var(--primary-color);
    text-decoration: underline;
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    color: rgba(255, 255, 255, 0.5);
    font-size: 0.875rem;
}

/* ===== Alerts ===== */
.alert {
    padding: 12px 16px;
    border-radius: var(--border-radius);
    margin-bottom: 20px;
    font-size: 0.9rem;
}

.alert-error {
    background: rgba(255, 82, 82, 0.1);
    color: var(--error-color);
    border: 1px solid rgba(255, 82, 82, 0.2);
}

.alert-success {
    background: rgba(0, 200, 83, 0.1);
    color: var(--success-color);
    border: 1px solid rgba(0, 200, 83, 0.2);
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    border-radius: var(--border-radius);
    transition: var(--transition-fast);
    white-space: nowrap;
}

.btn svg {
    width: 18px;
    height: 18px;
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

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

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

.btn-danger:hover {
    background: #e04545;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

.btn-sm svg {
    width: 14px;
    height: 14px;
}

/* ===== App Layout ===== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* ===== Sidebar ===== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: var(--transition-normal);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    max-height: 200px;
    width: auto;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 12px;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 4px;
    transition: var(--transition-fast);
}

.nav-item svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

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

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-info {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 12px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 1.1rem;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: white;
    font-weight: 500;
    font-size: 0.9rem;
}

.user-role {
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
}

.btn-logout {
    padding: 8px;
    border-radius: var(--border-radius);
    color: rgba(255, 255, 255, 0.6);
    transition: var(--transition-fast);
}

.btn-logout:hover {
    background: rgba(255, 82, 82, 0.2);
    color: var(--error-color);
}

.btn-logout svg {
    width: 20px;
    height: 20px;
}

/* ===== Main Content ===== */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
}

/* ===== Top Bar ===== */
.top-bar {
    height: var(--topbar-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.calendar-nav {
    display: flex;
    align-items: center;
    gap: 16px;
}

.nav-arrows {
    display: flex;
    gap: 4px;
}

.btn-arrow {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

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

.btn-arrow svg {
    width: 20px;
    height: 20px;
}

.current-period {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.top-bar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.search-box {
    position: relative;
}

.search-box svg {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    width: 18px;
    height: 18px;
    color: var(--text-light);
}

.search-box input {
    padding: 10px 16px 10px 40px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    width: 240px;
    transition: var(--transition-fast);
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
    width: 300px;
}

/* ===== Calendar ===== */
.calendar-container {
    flex: 1;
    padding: 24px;
    overflow-x: auto;
}

.calendar-header {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    margin-bottom: 12px;
}

.calendar-day-header {
    text-align: center;
    padding: 12px;
}

.day-name {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.day-number {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    font-size: 1.1rem;
    font-weight: 600;
    border-radius: 50%;
}

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

.calendar-body {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 12px;
    min-height: calc(100vh - var(--topbar-height) - 150px);
}

.calendar-day {
    background: var(--bg-card);
    border-radius: var(--border-radius);
    padding: 12px;
    min-height: 200px;
    border: 1px solid var(--border-color);
    transition: var(--transition-fast);
    overflow-y: auto;
    max-height: calc(100vh - 200px);
}

.calendar-day:hover {
    box-shadow: var(--shadow-md);
}

.calendar-day.today {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

/* ===== Pauta Cards ===== */
.pauta-card {
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 12px;
    margin-bottom: 8px;
    cursor: pointer;
    transition: var(--transition-fast);
    border-left: 3px solid var(--warning-color);
}

.pauta-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.pauta-card.published {
    border-left-color: var(--success-color);
    background: rgba(6, 172, 228, 0.05);
}

.pauta-card.pending {
    border-left-color: var(--warning-color);
}

.pauta-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.pauta-time {
    font-size: 0.75rem;
    color: var(--text-light);
}

.pauta-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 4px;
}

.pauta-status svg {
    width: 12px;
    height: 12px;
}

.pauta-status.published {
    background: rgba(6, 172, 228, 0.15);
    color: var(--success-color);
}

.pauta-status.pending {
    background: rgba(255, 193, 7, 0.15);
    color: #d39e00;
}

.pauta-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.pauta-creator {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.pauta-budget {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--accent-color);
}

/* ===== Modals ===== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal.active {
    display: flex;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

.modal-large {
    max-width: 800px;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid var(--border-color);
}

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.modal-close {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

.modal-close:hover {
    background: var(--bg-color);
    color: var(--text-primary);
}

.modal-close svg {
    width: 20px;
    height: 20px;
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

/* ===== Forms ===== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    transition: var(--transition-fast);
    background: var(--bg-card);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.form-row {
    margin-bottom: 16px;
}

.form-row:last-child {
    margin-bottom: 0;
}

.form-row.two-cols {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.radio-group {
    display: flex;
    gap: 20px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: 400;
}

.radio-label input[type="radio"] {
    width: auto;
}

/* ===== Pauta Details View ===== */
.pauta-details {
    display: grid;
    gap: 20px;
}

.pauta-meta {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 16px;
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

.meta-item {
    text-align: center;
}

.meta-label {
    display: block;
    font-size: 0.75rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    margin-bottom: 4px;
}

.meta-value {
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-primary);
}

.pauta-section {
    padding: 16px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

.pauta-section h4 {
    font-size: 0.9rem;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.pauta-description {
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ===== Comments Section ===== */
.comments-section {
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border-color);
}

.comments-section h4 {
    font-size: 1rem;
    font-weight: 600;
    margin-bottom: 16px;
}

.comments-list {
    max-height: 300px;
    overflow-y: auto;
    margin-bottom: 16px;
}

.comment-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    margin-bottom: 8px;
}

.comment-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-weight: 600;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.comment-content {
    flex: 1;
}

.comment-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
}

.comment-author {
    font-weight: 600;
    font-size: 0.9rem;
}

.comment-role {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--primary-light);
    color: var(--primary-color);
}

.comment-date {
    font-size: 0.75rem;
    color: var(--text-light);
    margin-left: auto;
}

.comment-text {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.5;
}

.comment-form {
    display: flex;
    gap: 12px;
}

.comment-form textarea {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    resize: none;
    min-height: 60px;
}

.comment-form textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===== Admin Pages ===== */
.page-container {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 24px;
}

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.page-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

/* ===== Tables ===== */
.table-container {
    background: var(--bg-card);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.table-filters {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-group label {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.filter-group input,
.filter-group select {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-color);
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-secondary);
}

.data-table tr:hover {
    background: var(--bg-color);
}

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

.editable-cell input {
    width: 100%;
    padding: 6px 10px;
    border: 1px solid transparent;
    border-radius: 4px;
    background: transparent;
    transition: var(--transition-fast);
}

.editable-cell input:hover {
    border-color: var(--border-color);
}

.editable-cell input:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--bg-card);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-badge.admin {
    background: rgba(138, 90, 255, 0.15);
    color: var(--accent-color);
}

.status-badge.colaborador {
    background: rgba(100, 116, 139, 0.15);
    color: var(--text-secondary);
}

.table-actions {
    display: flex;
    gap: 8px;
}

.btn-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
}

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

.btn-icon.danger:hover {
    background: rgba(255, 82, 82, 0.1);
    color: var(--error-color);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

/* ===== Empty State ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
}

.empty-state svg {
    width: 64px;
    height: 64px;
    margin-bottom: 16px;
    opacity: 0.4;
}

.empty-state h3 {
    font-size: 1.1rem;
    margin-bottom: 8px;
    color: var(--text-primary);
}

/* ===== Search Results ===== */
.search-results {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    right: 0;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    max-height: 400px;
    overflow-y: auto;
    z-index: 60;
}

.search-result-item {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-color);
    cursor: pointer;
    transition: var(--transition-fast);
}

.search-result-item:hover {
    background: var(--bg-color);
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-title {
    font-weight: 500;
    margin-bottom: 4px;
}

.search-result-meta {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

/* ===== Loading Spinner ===== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== TinyMCE Override ===== */
.tox-tinymce {
    border-radius: var(--border-radius) !important;
    border-color: var(--border-color) !important;
}

/* ===== Mobile Responsiveness ===== */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content,
    .page-container {
        margin-left: 0;
    }

    .calendar-header,
    .calendar-body {
        grid-template-columns: repeat(7, minmax(120px, 1fr));
    }
}

@media (max-width: 768px) {
    html {
        font-size: 13px;
    }

    .top-bar {
        flex-direction: column;
        height: auto;
        padding: 12px 16px;
        gap: 12px;
    }

    .calendar-nav {
        width: 100%;
        flex-wrap: wrap;
    }

    .current-period {
        font-size: 1rem;
        order: -1;
        width: 100%;
        text-align: center;
    }

    .top-bar-actions {
        width: 100%;
        flex-wrap: wrap;
    }

    .search-box {
        flex: 1;
        min-width: 200px;
    }

    .search-box input {
        width: 100%;
    }

    .search-box input:focus {
        width: 100%;
    }

    .btn-primary {
        width: 100%;
    }

    .calendar-container {
        padding: 12px;
    }

    /* Hide the separate calendar header on mobile */
    .calendar-header {
        display: none;
    }

    .calendar-body {
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    .calendar-day {
        min-height: auto;
        padding: 0;
        margin-bottom: 0;
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        overflow: hidden;
    }

    .calendar-day::before {
        content: attr(data-date-display);
        display: block;
        padding: 12px 16px;
        background: var(--bg-card);
        font-weight: 600;
        color: var(--text-primary);
        border-bottom: 1px solid var(--border-color);
    }

    .calendar-day.today::before {
        background: var(--primary-color);
        color: white;
    }

    .calendar-day:empty::before {
        border-bottom: none;
    }

    /* Style the pauta cards container inside day */
    .calendar-day .pauta-card:first-child {
        margin-top: 12px;
    }

    .calendar-day .pauta-card {
        margin: 0 12px 12px 12px;
    }

    .form-row.two-cols {
        grid-template-columns: 1fr;
    }

    .modal-content {
        max-height: 100vh;
        border-radius: 0;
    }

    .modal {
        padding: 0;
    }

    .table-filters {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .table-filters .filter-group {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

    .table-filters .filter-group input {
        width: 100%;
    }

    .table-filters .btn {
        width: 100%;
    }

    /* Card-based table layout for mobile */
    .data-table {
        display: block;
    }

    .data-table thead {
        display: none;
    }

    .data-table tbody {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .data-table tr {
        display: block;
        background: var(--bg-card);
        border: 1px solid var(--border-color);
        border-radius: var(--border-radius);
        padding: 16px;
        box-shadow: var(--shadow-sm);
    }

    .data-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 8px 0;
        border-bottom: 1px solid var(--border-color);
    }

    .data-table td:last-child {
        border-bottom: none;
        padding-top: 12px;
        justify-content: center;
    }

    .data-table td::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-secondary);
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    /* Hide less important columns on mobile */
    .data-table td:nth-child(n+6):not(:last-child) {
        display: none;
    }

    .data-table td:nth-child(1) {
        font-weight: 600;
        font-size: 1rem;
        color: var(--primary-color);
        padding-bottom: 12px;
        border-bottom: 2px solid var(--primary-color);
    }

    .data-table td:nth-child(1)::before {
        display: none;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .page-header h1 {
        font-size: 1.5rem;
    }

    .page-header .btn {
        width: 100%;
    }

    /* Analytics modal adjustments for mobile */
    .analytics-container {
        padding: 0;
    }

    .kpi-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px;
    }

    .kpi-card {
        padding: 12px;
    }

    .kpi-value {
        font-size: 1.25rem;
    }

    .metric-bar-row {
        flex-wrap: wrap;
    }

    .metric-label {
        width: 100%;
        margin-bottom: 4px;
    }

    .metric-value {
        position: absolute;
        right: 8px;
    }

    .metric-bar {
        width: 100%;
    }
}

/* ===== Mobile Menu Toggle ===== */
.mobile-menu-toggle {
    display: none;
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    box-shadow: var(--shadow-lg);
    z-index: 90;
    align-items: center;
    justify-content: center;
}

.mobile-menu-toggle svg {
    width: 24px;
    height: 24px;
}

@media (max-width: 1024px) {
    .mobile-menu-toggle {
        display: flex;
    }
}

/* ===== Print Styles ===== */
@media print {

    .sidebar,
    .top-bar,
    .modal,
    .btn,
    .table-actions {
        display: none !important;
    }

    .main-content,
    .page-container {
        margin-left: 0;
    }

    .data-table th,
    .data-table td {
        padding: 8px 12px;
    }
}

/* ===== View Toggle ===== */
.view-toggle {
    display: flex;
    gap: 4px;
    margin-left: 16px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
    padding: 4px;
}

.view-toggle-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    border-radius: calc(var(--border-radius) - 2px);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    text-decoration: none;
}

.view-toggle-btn:hover {
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.03);
}

.view-toggle-btn.active {
    background: var(--bg-card);
    color: var(--primary-color);
    box-shadow: var(--shadow-sm);
}

.view-toggle-btn svg {
    width: 16px;
    height: 16px;
}

/* ===== Month View Calendar ===== */
.calendar-container.month-view {
    padding: 16px;
}

.calendar-month-header .calendar-day-header {
    padding: 8px;
}

.calendar-month-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
    min-height: calc(100vh - var(--topbar-height) - 100px);
}

.calendar-day-month {
    min-height: 100px;
    max-height: 150px;
    padding: 6px;
    background: var(--bg-card);
    border-radius: var(--border-radius);
    border: 1px solid var(--border-color);
    overflow-y: auto;
}

.calendar-day-month.today {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 1px var(--primary-color);
}

.calendar-day-month.other-month {
    background: var(--bg-color);
    opacity: 0.6;
}

.calendar-day-month.other-month .day-number {
    color: var(--text-light);
}

.month-day-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 4px;
}

.day-name-mobile {
    display: none;
}

.month-day-header .day-number {
    width: 24px;
    height: 24px;
    font-size: 0.8rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.month-day-header .today-number {
    background: var(--primary-color);
    color: white;
}

.month-day-content {
    display: flex;
    flex-direction: column;
    gap: 3px;
}

/* ===== Compact Pauta Cards (Month View) ===== */
.pauta-card-compact {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 4px 6px;
    margin-bottom: 0;
    border-radius: 4px;
    cursor: pointer;
    transition: var(--transition-fast);
    border-left: 2px solid var(--warning-color);
    background: rgba(255, 193, 7, 0.08);
}

.pauta-card-compact:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}

.pauta-card-compact.published {
    border-left-color: var(--success-color);
    background: rgba(6, 172, 228, 0.08);
}

.pauta-card-compact.pending {
    border-left-color: var(--warning-color);
}

.pauta-title-compact {
    flex: 1;
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.2;
}

.pauta-status-compact {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 14px;
    height: 14px;
    font-size: 0.65rem;
}

.pauta-status-compact.published {
    color: var(--success-color);
}

.pauta-status-compact.published svg {
    width: 10px;
    height: 10px;
}

.pauta-status-compact.pending {
    color: var(--warning-color);
    font-size: 0.5rem;
}

/* ===== Responsive adjustments for month view ===== */
@media (max-width: 1024px) {
    .view-toggle {
        margin-left: 8px;
    }

    .view-toggle-btn span {
        display: none;
    }

    .calendar-day-month {
        min-height: 80px;
        padding: 4px;
    }

    .pauta-title-compact {
        font-size: 0.65rem;
    }
}

@media (max-width: 768px) {
    .calendar-nav {
        flex-wrap: wrap;
        gap: 8px;
    }

    .view-toggle {
        order: -1;
        width: 100%;
        justify-content: center;
    }

    /* Month view mobile: vertical list like week view */
    .calendar-container.month-view .calendar-month-header {
        display: none;
    }

    .calendar-container.month-view .calendar-month-grid {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .calendar-container.month-view .calendar-day-month {
        min-height: auto;
        max-height: none;
        padding: 12px;
        border-radius: var(--border-radius);
        border: 1px solid var(--border-color);
        background: var(--bg-card);
        opacity: 1;
    }

    .calendar-container.month-view .calendar-day-month.other-month {
        display: none;
    }

    .calendar-container.month-view .month-day-header {
        justify-content: flex-start;
        margin-bottom: 12px;
        padding-bottom: 8px;
        border-bottom: 1px solid var(--border-color);
    }

    .calendar-container.month-view .month-day-header .day-number {
        width: auto;
        height: auto;
        font-size: 1rem;
        font-weight: 600;
        padding: 0;
    }

    .calendar-container.month-view .day-name-mobile {
        display: inline;
        font-weight: 500;
        color: var(--text-secondary);
        margin-right: 8px;
        font-size: 0.9rem;
    }

    .calendar-container.month-view .calendar-day-month.today {
        border-color: var(--primary-color);
        box-shadow: 0 0 0 2px var(--primary-light);
    }

    /* Use full card style in mobile month view */
    .calendar-container.month-view .pauta-card-compact {
        display: block;
        padding: 12px;
        margin-bottom: 8px;
        border-radius: var(--border-radius);
        border-left: 3px solid var(--warning-color);
        background: var(--bg-color);
    }

    .calendar-container.month-view .pauta-card-compact.published {
        border-left-color: var(--success-color);
        background: rgba(6, 172, 228, 0.05);
    }

    .calendar-container.month-view .pauta-title-compact {
        display: block;
        font-size: 0.9rem;
        font-weight: 600;
        white-space: normal;
        overflow: visible;
        text-overflow: clip;
        line-height: 1.4;
        margin-bottom: 4px;
    }

    .calendar-container.month-view .pauta-status-compact {
        display: inline-flex;
        align-items: center;
        gap: 4px;
        font-size: 0.7rem;
        font-weight: 500;
        padding: 2px 6px;
        border-radius: 4px;
        width: auto;
        height: auto;
    }

    .calendar-container.month-view .pauta-status-compact.published {
        background: rgba(6, 172, 228, 0.15);
        color: var(--success-color);
    }

    .calendar-container.month-view .pauta-status-compact.published::after {
        content: 'Publicado';
    }

    .calendar-container.month-view .pauta-status-compact.published svg {
        width: 12px;
        height: 12px;
    }

    .calendar-container.month-view .pauta-status-compact.pending {
        background: rgba(255, 193, 7, 0.15);
        color: #d39e00;
        font-size: 0.7rem;
    }

    .calendar-container.month-view .pauta-status-compact.pending::after {
        content: 'Pendiente';
    }

    .calendar-container.month-view .month-day-content {
        gap: 8px;
    }
}

/* ===== Resource URL Rows ===== */
.resource-url-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.resource-url-row .resource-url-input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 0.9rem;
    transition: var(--transition-fast);
}

.resource-url-row .resource-url-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-remove-url {
    width: 32px;
    height: 32px;
    border-radius: var(--border-radius);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    flex-shrink: 0;
}

.btn-remove-url:hover {
    background: rgba(255, 82, 82, 0.1);
    color: var(--error-color);
}

/* ===== Icon Buttons for Tables ===== */
.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: var(--border-radius);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    transition: var(--transition-fast);
    border: 1px solid var(--border-color);
    background: transparent;
}

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

.btn-icon.danger:hover {
    background: rgba(255, 82, 82, 0.1);
    color: var(--error-color);
    border-color: var(--error-color);
}

.btn-icon svg {
    width: 16px;
    height: 16px;
}

.table-actions {
    display: flex;
    gap: 6px;
    justify-content: center;
}

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

.btn-success:hover {
    opacity: 0.9;
}

.action-buttons {
    display: flex;
    gap: 6px;
}