/* ==========================================
   Calendar App - Modern Orange Theme
   Font: Inter (Google Fonts)
   ========================================== */

/* --- Reset & Base --- */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --orange-50: #fff7ed;
    --orange-100: #ffedd5;
    --orange-200: #fed7aa;
    --orange-300: #fdba74;
    --orange-400: #fb923c;
    --orange-500: #f97316;
    --orange-600: #ea580c;
    --orange-700: #c2410c;
    --orange-800: #9a3412;

    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    --red-500: #ef4444;
    --red-600: #dc2626;
    --green-500: #22c55e;
    --blue-500: #3b82f6;
    --purple-500: #8b5cf6;

    --conv1: #f97316;
    --conv1-bg: #fff7ed;
    --conv2: #3b82f6;
    --conv2-bg: #eff6ff;
    --conv3: #22c55e;
    --conv3-bg: #f0fdf4;
    --conv4: #8b5cf6;
    --conv4-bg: #f5f3ff;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, .05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, .07), 0 2px 4px -2px rgba(0, 0, 0, .05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, .08), 0 4px 6px -4px rgba(0, 0, 0, .05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, .1), 0 8px 10px -6px rgba(0, 0, 0, .08);

    --transition: 200ms cubic-bezier(.4, 0, .2, 1);
}

html {
    font-size: 14px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: linear-gradient(135deg, var(--orange-50) 0%, #fff 50%, var(--gray-50) 100%);
    color: var(--gray-800);
    min-height: 100vh;
    line-height: 1.6;
}

/* --- Navbar --- */
.navbar {
    background: linear-gradient(135deg, var(--orange-600) 0%, var(--orange-500) 100%);
    color: #fff;
    padding: .8rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 20px rgba(249, 115, 22, .25);
    position: sticky;
    top: 0;
    z-index: 100;
}

.navbar-brand {
    display: flex;
    align-items: center;
    gap: .6rem;
}

.navbar-brand h1 {
    font-size: 1.25rem;
    font-weight: 700;
    letter-spacing: -.02em;
}

.navbar-icon {
    font-size: 1.5rem;
}

.navbar-logo {
    height: 38px;
    width: 38px;
    object-fit: contain;
    border-radius: 50%;
    background: #fff;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
}

.navbar-actions {
    display: flex;
    align-items: center;
    gap: .75rem;
    flex-wrap: wrap;
}

.user-badge {
    display: flex;
    align-items: center;
    gap: .4rem;
    background: rgba(255, 255, 255, .18);
    backdrop-filter: blur(10px);
    padding: .35rem .75rem;
    border-radius: 999px;
    font-size: .8rem;
    font-weight: 500;
}

.badge-dot {
    width: 7px;
    height: 7px;
    background: var(--green-500);
    border-radius: 50%;
    display: inline-block;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: .6;
        transform: scale(1.3);
    }
}

/* --- Datos ---*/
.datos{
    
    border: 1px solid #fb6d00;
    margin: 25px 0;
    font-size: 0.9em;
    font-family: sans-serif;
    min-width: 400px;
    width: 100%;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.15); /* Sombra sutil */
    border-radius: 5px 5px 0 0;
    overflow: hidden;
}
.datos td{
    text-align: left;
    border-top: 1px solid #fb6d00;
}

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    padding: .5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    font-size: .85rem;
    border: none;
    cursor: pointer;
    transition: all var(--transition);
    text-decoration: none;
    line-height: 1.4;
    white-space: nowrap;
}

.btn:active {
    transform: scale(.97);
}

.btn-primary {
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    color: #fff;
    box-shadow: 0 2px 8px rgba(249, 115, 22, .3);
}

.btn-primary:hover {
    background: linear-gradient(135deg, var(--orange-600), var(--orange-700));
    box-shadow: 0 4px 12px rgba(249, 115, 22, .4);
}

.btn-outline {
    background: transparent;
    border: 1.5px solid var(--gray-300);
    color: var(--gray-600);
}

.btn-outline:hover {
    border-color: var(--orange-400);
    color: var(--orange-500);
}

.btn-danger {
    background: var(--red-500);
    color: #fff;
    box-shadow: 0 2px 8px rgba(239, 68, 68, .3);
}

.btn-danger:hover {
    background: var(--red-600);
}

.btn-icon {
    background: rgba(255, 255, 255, .15);
    border: 1.5px solid var(--orange-300);
    color: var(--orange-600);
    width: 38px;
    height: 38px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all var(--transition);
}

.btn-icon:hover {
    background: var(--orange-500);
    color: #fff;
    border-color: var(--orange-500);
    box-shadow: 0 4px 12px rgba(249, 115, 22, .3);
}

.btn-sm {
    padding: .3rem .7rem;
    font-size: .78rem;
}

.btn-block {
    width: 100%;
    justify-content: center;
    padding: .65rem 1rem;
    font-size: .95rem;
}

.btn-loader {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, .3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* --- Month Navigation --- */
.month-nav {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1rem;
    padding: 1.2rem 1rem .6rem;
}

.month-selectors {
    display: flex;
    align-items: center;
    gap: .5rem;
}

.month-select,
.year-select {
    padding: .45rem .75rem;
    border: 2px solid var(--orange-300);
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 1rem;
    font-weight: 700;
    color: var(--gray-800);
    background: #fff;
    cursor: pointer;
    transition: all var(--transition);
    appearance: auto;
}

.month-select:focus,
.year-select:focus {
    outline: none;
    border-color: var(--orange-500);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .15);
}

.month-select:hover,
.year-select:hover {
    border-color: var(--orange-500);
}

.month-select {
    min-width: 150px;
}

.year-select {
    min-width: 90px;
}

/* --- Legend --- */
.legend-bar {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    padding: .4rem 1rem .8rem;
    flex-wrap: wrap;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: .35rem;
    font-size: .78rem;
    color: var(--gray-600);
    font-weight: 500;
}

.legend-color {
    width: 12px;
    height: 12px;
    border-radius: 3px;
    display: inline-block;
}

.legend-color.conv-1 {
    background: var(--conv1);
}

.legend-color.conv-2 {
    background: var(--conv2);
}

.legend-color.conv-3 {
    background: var(--conv3);
}

.legend-color.conv-4 {
    background: var(--conv4);
}

/* --- Calendar --- */
.calendar-wrapper {
    max-width: 1200px;
    margin: 0 auto 2rem;
    padding: 0 1rem;
}

.calendar-header {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    margin-bottom: 1px;
}

.cal-head-cell {
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    color: #fff;
    font-weight: 600;
    font-size: .8rem;
    text-align: center;
    padding: .6rem .3rem;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.cal-head-cell:first-child {
    border-radius: var(--radius-md) 0 0 0;
}

.cal-head-cell:last-child {
    border-radius: 0 var(--radius-md) 0 0;
}

.cal-head-cell.weekend {
    background: linear-gradient(135deg, var(--gray-600), var(--gray-700));
}

.calendar-grid {
    display: grid;
    grid-template-columns: 60px repeat(7, 1fr);
    gap: 1px;
    background: var(--gray-200);
    border-radius: 0 0 var(--radius-md) var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-lg);
}

.week-number {
    background: var(--orange-50);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: .75rem;
    color: var(--orange-600);
    border-right: 2px solid var(--orange-200);
}

.cal-day {
    background: #fff;
    min-height: 100px;
    padding: .4rem;
    display: flex;
    flex-direction: column;
    transition: background var(--transition);
    position: relative;
    overflow: hidden;
    min-width: 0;
}

.cal-day:hover {
    background: var(--orange-50);
}

.cal-day.weekend {
    background: var(--gray-100);
}

.cal-day.weekend:hover {
    background: var(--gray-200);
}

.cal-day.other-month {
    opacity: .45;
}

.cal-day.today {
    box-shadow: inset 0 0 0 2px var(--orange-400);
}

.cal-day.admin-clickable {
    cursor: pointer;
}

.day-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: .3rem;
}

.day-number {
    font-weight: 700;
    font-size: .9rem;
    color: var(--gray-700);
}

.day-name {
    font-size: .65rem;
    color: var(--gray-400);
    font-weight: 500;
    text-transform: uppercase;
}

.day-activities {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow: hidden;
    min-width: 0;
}

.activity-pill {
    padding: .2rem .4rem;
    border-radius: 4px;
    font-size: .7rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--transition);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    border-left: 3px solid transparent;
    max-width: 100%;
    display: block;
}

.activity-pill:hover {
    transform: translateX(2px);
    box-shadow: var(--shadow-sm);
}

.activity-pill.conv-1 {
    background: var(--conv1-bg);
    color: var(--orange-700);
    border-left-color: var(--conv1);
}

.activity-pill.conv-2 {
    background: var(--conv2-bg);
    color: #1e40af;
    border-left-color: var(--conv2);
}

.activity-pill.conv-3 {
    background: var(--conv3-bg);
    color: #15803d;
    border-left-color: var(--conv3);
}

.activity-pill.conv-4 {
    background: var(--conv4-bg);
    color: #6d28d9;
    border-left-color: var(--conv4);
}

/* --- Modal --- */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn .2s ease;
    padding: 1rem;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: #fff;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 480px;
    box-shadow: var(--shadow-xl);
    animation: slideUp .25s ease;
    overflow: hidden;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--gray-200);
}

.modal-header h3 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--gray-800);
}

.modal-header-primary {
    background: linear-gradient(135deg, var(--orange-500), var(--orange-600));
    border-bottom-color: transparent;
}

.modal-header-primary h3 {
    color: #fff;
}

.modal-header-primary .modal-close {
    color: #fff;
}

.modal-header-edit {
    background: linear-gradient(135deg, var(--gray-700), var(--gray-800));
    border-bottom-color: transparent;
}

.modal-header-edit h3 {
    color: #fff;
}

.modal-header-edit .modal-close {
    color: #fff;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--gray-400);
    line-height: 1;
    transition: color var(--transition);
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.modal-close:hover {
    color: var(--gray-800);
    background: var(--gray-100);
}

.modal-header-primary .modal-close:hover,
.modal-header-edit .modal-close:hover {
    background: rgba(255, 255, 255, .2);
    color: #fff;
}

.modal-body {
    padding: 1.25rem;
}

.modal-footer {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: .6rem;
    padding: .8rem 1.25rem;
    border-top: 1px solid var(--gray-200);
    background: var(--gray-50);
}

.modal-footer-right {
    display: flex;
    gap: .6rem;
    margin-left: auto;
}

/* --- Detail groups --- */
.detail-group {
    margin-bottom: 1rem;
}

.detail-group:last-child {
    margin-bottom: 0;
}

.detail-group label {
    display: block;
    font-size: .75rem;
    font-weight: 600;
    color: var(--gray-400);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-bottom: .2rem;
}

.detail-group p {
    font-size: .95rem;
    color: var(--gray-800);
    font-weight: 500;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: var(--gray-700);
    margin-bottom: .3rem;
}

.form-control {
    width: 100%;
    padding: .55rem .75rem;
    border: 1.5px solid var(--gray-300);
    border-radius: var(--radius-sm);
    font-size: .9rem;
    font-family: inherit;
    color: var(--gray-800);
    transition: all var(--transition);
    background: #fff;
}

.form-control:focus {
    outline: none;
    border-color: var(--orange-400);
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .12);
}

textarea.form-control {
    resize: vertical;
}

select.form-control {
    cursor: pointer;
}

.form-errors {
    background: #fef2f2;
    color: var(--red-600);
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    font-size: .82rem;
    margin-top: .5rem;
    border: 1px solid #fecaca;
}

/* --- Toast --- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: .7rem 1.2rem;
    background: var(--gray-800);
    color: #fff;
    border-radius: var(--radius-md);
    font-size: .85rem;
    font-weight: 500;
    box-shadow: var(--shadow-xl);
    z-index: 2000;
    animation: slideUp .3s ease;
    max-width: 350px;
}

.toast.success {
    background: linear-gradient(135deg, #15803d, #22c55e);
}

.toast.error {
    background: linear-gradient(135deg, #dc2626, #ef4444);
}

/* --- Login Page --- */
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, var(--orange-600) 0%, var(--orange-400) 50%, var(--orange-300) 100%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    padding: 1rem;
}

.login-card {
    background: #fff;
    border-radius: var(--radius-xl);
    padding: 2rem;
    box-shadow: var(--shadow-xl), 0 0 60px rgba(249, 115, 22, .15);
}

.login-header {
    text-align: center;
    margin-bottom: 1.5rem;
}

.login-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: .5rem;
}

.login-header h1 {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--gray-800);
    margin-bottom: .2rem;
}

.login-header p {
    color: var(--gray-500);
    font-size: .85rem;
}

.login-back {
    display: block;
    text-align: center;
    margin-top: 1.2rem;
    color: var(--orange-500);
    text-decoration: none;
    font-size: .85rem;
    font-weight: 500;
    transition: color var(--transition);
}

.login-back:hover {
    color: var(--orange-700);
}

/* --- Add Button on Day Cell --- */
.day-add-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 20px;
    height: 20px;
    border: none;
    background: var(--orange-500);
    color: #fff;
    border-radius: 50%;
    font-size: .8rem;
    font-weight: 700;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: all var(--transition);
    line-height: 1;
}

.cal-day:hover .day-add-btn {
    opacity: 1;
}

.day-add-btn:hover {
    background: var(--orange-600);
    transform: scale(1.15);
}

/* --- Responsive --- */
@media (max-width: 1100px) {
    .calendar-wrapper {
        padding: 0 .5rem;
    }

    .cal-day {
        min-height: 85px;
    }
}

@media (max-width: 900px) {
    .navbar {
        flex-wrap: wrap;
        gap: .5rem;
        justify-content: center;
    }

    .navbar-brand {
        justify-content: center;
    }

    .navbar-actions {
        justify-content: center;
    }

    .calendar-header,
    .calendar-grid {
        grid-template-columns: 35px repeat(7, 1fr);
    }

    .week-number {
        font-size: .6rem;
    }

    .cal-day {
        min-height: 70px;
        padding: .25rem;
    }

    .activity-pill {
        font-size: .55rem;
        padding: .12rem .25rem;
        border-left-width: 2px;
    }

    .day-number {
        font-size: .7rem;
    }

    .day-name {
        display: none;
    }

    .month-select {
        min-width: 120px;
        font-size: .85rem;
    }

    .year-select {
        min-width: 75px;
        font-size: .85rem;
    }

    .modal {
        max-width: 95vw;
    }
}

@media (max-width: 600px) {
    .navbar {
        padding: .5rem .8rem;
    }

    .navbar-brand h1 {
        font-size: .9rem;
    }

    .navbar-logo {
        height: 30px;
        width: 30px;
    }

    .legend-bar {
        gap: .5rem;
        padding: .3rem .5rem .6rem;
    }

    .legend-item {
        font-size: .65rem;
    }

    .month-nav {
        padding: .8rem .5rem .4rem;
        gap: .6rem;
    }

    .month-select {
        min-width: 100px;
        font-size: .8rem;
        padding: .35rem .5rem;
    }

    .year-select {
        min-width: 65px;
        font-size: .8rem;
        padding: .35rem .5rem;
    }

    .calendar-header,
    .calendar-grid {
        grid-template-columns: 25px repeat(7, 1fr);
    }

    .cal-head-cell {
        font-size: .5rem;
        padding: .35rem .1rem;
        letter-spacing: 0;
    }

    .cal-day {
        min-height: 55px;
        padding: .2rem;
    }

    .day-number {
        font-size: .65rem;
    }

    .activity-pill {
        font-size: .5rem;
        padding: .1rem .2rem;
    }

    .day-add-btn {
        width: 16px;
        height: 16px;
        font-size: .6rem;
    }

    .btn-sm {
        padding: .25rem .5rem;
        font-size: .7rem;
    }

    .user-badge {
        font-size: .7rem;
        padding: .25rem .5rem;
    }
}

@media (max-width: 420px) {
    .navbar-brand h1 {
        font-size: .8rem;
    }

    .calendar-header,
    .calendar-grid {
        grid-template-columns: 20px repeat(7, 1fr);
    }

    .cal-head-cell {
        font-size: .45rem;
    }

    .cal-day {
        min-height: 45px;
    }

    .activity-pill {
        font-size: .45rem;
        max-width: 100%;
    }

    .legend-bar {
        gap: .3rem;
    }

    .legend-item {
        font-size: .55rem;
    }

    .legend-color {
        width: 8px;
        height: 8px;
    }

    .month-selectors {
        gap: .3rem;
    }

    .month-select {
        min-width: 85px;
        font-size: .75rem;
    }

    .year-select {
        min-width: 60px;
        font-size: .75rem;
    }
}