/* ==========================================================
   AGENDA PASTORAL — PRMAR.CO
   ========================================================== */

:root{
    --bg:#080b0f;
    --surface:#10151c;
    --surface-hover:#19212c;
    --surface-muted:#0c1117;
    --border:#2a3543;
    --text:#f4f7fb;
    --text-secondary:#9eabbc;
    --primary:#2f81f7;
    --shadow:0 20px 50px rgba(0,0,0,.35);
    --radius:18px;
    --toolbar-height:104px;
}

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

html,
body{
    width:100%;
    height:100%;
    overflow:hidden;
}

body{
    background:
        radial-gradient(circle at 85% -10%,rgba(47,129,247,.15),transparent 34rem),
        linear-gradient(145deg,#080b0f,#0b1017);
    color:var(--text);
    font-family:"Inter",system-ui,-apple-system,BlinkMacSystemFont,"Segoe UI",sans-serif;
}

button,
input{
    font:inherit;
}

button{
    border:0;
    cursor:pointer;
}

#app{
    display:flex;
    flex-direction:column;
    width:100%;
    height:100dvh;
    min-height:0;
}

#topbar{
    display:flex;
    flex:0 0 auto;
    align-items:center;
    justify-content:space-between;
    gap:24px;
    min-height:var(--toolbar-height);
    padding:18px 28px;
    background:rgba(16,21,28,.94);
    border-bottom:1px solid var(--border);
    box-shadow:var(--shadow);
    backdrop-filter:blur(16px);
    z-index:10;
}

#titleArea{
    display:flex;
    flex:0 0 auto;
    flex-direction:column;
    gap:4px;
}

#titleArea h1{
    color:var(--text);
    font-size:clamp(26px,3vw,42px);
    font-weight:800;
    letter-spacing:-.04em;
    line-height:1;
}

#titleArea p{
    color:var(--text-secondary);
    font-size:14px;
}

#toolbar{
    display:flex;
    align-items:center;
    justify-content:flex-end;
    gap:10px;
    min-width:0;
}

#toolbar button{
    display:inline-flex;
    align-items:center;
    justify-content:center;
    height:42px;
    min-width:42px;
    padding:0 16px;
    background:var(--surface-hover);
    border:1px solid var(--border);
    border-radius:12px;
    color:var(--text);
    font-weight:700;
    transition:background .18s ease,border-color .18s ease,transform .18s ease;
}

#toolbar button:hover{
    background:#253143;
    border-color:#44546a;
    transform:translateY(-1px);
}

#currentMonth{
    min-width:180px;
    color:var(--text);
    font-size:20px;
    font-weight:800;
    text-align:center;
    text-transform:capitalize;
}

#searchBox{
    width:min(280px,24vw);
    height:42px;
    padding:0 14px;
    background:var(--surface-hover);
    border:1px solid var(--border);
    border-radius:12px;
    color:var(--text);
    outline:none;
    transition:border-color .18s ease,box-shadow .18s ease;
}

#searchBox::placeholder{
    color:var(--text-secondary);
}

#searchBox:focus{
    border-color:var(--primary);
    box-shadow:0 0 0 3px rgba(47,129,247,.16);
}

#calendarContainer{
    flex:1 1 auto;
    min-width:0;
    min-height:0;
    padding:14px;
    overflow:hidden;
}

#calendar{
    display:flex;
    flex-direction:column;
    width:100%;
    height:100%;
    min-height:0;
    overflow:hidden;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:var(--radius);
    box-shadow:var(--shadow);
}

.calendar-week-header{
    display:grid;
    flex:0 0 auto;
    grid-template-columns:repeat(7,minmax(0,1fr));
    background:#181d24;
    border-bottom:1px solid var(--border);
}

.calendar-week-day{
    padding:12px 6px;
    border-right:1px solid var(--border);
    color:var(--text-secondary);
    font-size:13px;
    font-weight:700;
    text-align:center;
    text-transform:uppercase;
}

.calendar-week-day:last-child{
    border-right:0;
}

.calendar-grid{
    display:grid;
    flex:1 1 auto;
    grid-template-columns:repeat(7,minmax(0,1fr));
    grid-template-rows:repeat(6,minmax(0,1fr));
    width:100%;
    min-height:0;
    overflow:hidden;
}

.calendar-day{
    display:flex;
    flex-direction:column;
    min-width:0;
    min-height:0;
    padding:7px;
    overflow:hidden;
    background:#11161d;
    border-right:1px solid var(--border);
    border-bottom:1px solid var(--border);
}

.calendar-day:nth-child(7n){
    border-right:0;
}

.calendar-day:nth-last-child(-n+7){
    border-bottom:0;
}

.calendar-day.outside-month{
    background:#0c1117;
    color:#5f6b79;
}

.calendar-day.today{
    background:#17263a;
}

.day-number{
    display:flex;
    flex:0 0 auto;
    align-items:center;
    justify-content:center;
    width:30px;
    height:30px;
    margin-bottom:5px;
    border-radius:50%;
    font-size:13px;
    font-weight:800;
}

.calendar-day.today .day-number{
    background:var(--primary);
    color:#fff;
}

.event-container{
    display:flex;
    flex:1 1 auto;
    flex-direction:column;
    gap:4px;
    min-height:0;
    overflow:hidden;
}

.calendar-event{
    flex:0 0 auto;
    min-width:0;
    padding:4px 7px;
    overflow:hidden;
    border-radius:7px;
    font-size:11px;
    font-weight:700;
    line-height:1.25;
    text-overflow:ellipsis;
    white-space:nowrap;
    cursor:pointer;
    transition:filter .15s ease,transform .15s ease;
}

.calendar-event:hover{
    filter:brightness(1.1);
    transform:translateY(-1px);
}

.calendar-event:active{
    transform:none;
}

.calendar-event[hidden]{
    display:none;
}

.calendar-more-events{
    flex:0 0 auto;
    min-height:18px;
    padding:2px 7px;
    overflow:hidden;
    background:#252c36;
    border-radius:7px;
    color:var(--text-secondary);
    font-size:10px;
    font-weight:700;
    line-height:14px;
    text-overflow:ellipsis;
    white-space:nowrap;
    user-select:none;
}

dialog{
    width:min(560px,calc(100% - 28px));
    margin:auto;
    overflow:hidden;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:20px;
    color:var(--text);
    box-shadow:0 30px 100px rgba(0,0,0,.65);
}

dialog::backdrop{
    background:rgba(0,0,0,.7);
    backdrop-filter:blur(5px);
}

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

.dialogHeader h2{
    font-size:22px;
}

#dialogClose{
    display:grid;
    flex:0 0 auto;
    place-items:center;
    width:40px;
    height:40px;
    background:transparent;
    border-radius:50%;
    color:var(--text);
}

#dialogClose:hover{
    background:var(--surface-hover);
}

.dialogBody{
    display:flex;
    flex-direction:column;
    gap:20px;
    padding:24px;
}

.dialogBody strong{
    display:block;
    margin-bottom:6px;
    color:var(--primary);
    font-size:12px;
    text-transform:uppercase;
}

.dialogBody p{
    color:var(--text-secondary);
    line-height:1.5;
    white-space:pre-wrap;
}

dialog footer{
    padding:18px 24px 24px;
}

#eventGoogle{
    display:flex;
    align-items:center;
    justify-content:center;
    width:100%;
    min-height:46px;
    background:var(--primary);
    border-radius:12px;
    color:#fff;
    font-weight:800;
    text-decoration:none;
}

#eventGoogle:hover{
    filter:brightness(1.08);
}

#loadingOverlay{
    position:fixed;
    inset:0;
    display:flex;
    align-items:center;
    justify-content:center;
    background:rgba(8,11,15,.75);
    backdrop-filter:blur(6px);
    z-index:9999;
    transition:opacity .2s ease,visibility .2s ease;
}

#loadingOverlay.hidden{
    opacity:0;
    visibility:hidden;
    pointer-events:none;
}

.loading-card{
    width:min(320px,calc(100% - 32px));
    padding:34px;
    background:var(--surface);
    border:1px solid var(--border);
    border-radius:20px;
    box-shadow:var(--shadow);
    text-align:center;
}

.loading-card h2{
    margin-top:20px;
    font-size:20px;
}

.loading-card p{
    margin-top:8px;
    color:var(--text-secondary);
}

.spinner{
    width:50px;
    height:50px;
    margin:auto;
    border:5px solid #2d3748;
    border-top-color:var(--primary);
    border-radius:50%;
    animation:spin .8s linear infinite;
}

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

@media (max-width:1050px){
    :root{
        --toolbar-height:auto;
    }

    #topbar{
        align-items:flex-start;
        flex-direction:column;
        gap:14px;
        padding:14px 18px;
    }

    #toolbar{
        justify-content:flex-start;
        width:100%;
    }

    #searchBox{
        flex:1;
        width:auto;
    }
}

@media (max-width:700px){
    html,
    body{
        height:auto;
        min-height:100%;
        overflow-x:hidden;
        overflow-y:auto;
    }

    #app{
        height:auto;
        min-height:100dvh;
    }

    #topbar{
        position:static;
    }

    #toolbar{
        flex-wrap:wrap;
    }

    #currentMonth{
        order:3;
        width:100%;
        min-width:0;
        text-align:left;
    }

    #searchBox{
        order:4;
        flex-basis:100%;
        width:100%;
    }

    #calendarContainer{
        min-height:720px;
        padding:8px;
        overflow:auto;
    }

    #calendar{
        min-width:680px;
        min-height:700px;
    }

    .calendar-week-day{
        padding:9px 2px;
        font-size:11px;
    }

    .calendar-day{
        padding:5px;
    }

    .calendar-event{
        padding:3px 5px;
        font-size:10px;
    }
}

@media (max-height:760px) and (min-width:701px){
    #topbar{
        min-height:82px;
        padding-block:10px;
    }

    #titleArea h1{
        font-size:28px;
    }

    #titleArea p{
        display:none;
    }

    #calendarContainer{
        padding:8px;
    }

    .calendar-week-day{
        padding-block:8px;
    }

    .day-number{
        width:25px;
        height:25px;
        margin-bottom:3px;
    }

    .calendar-event{
        padding-block:2px;
        font-size:10px;
    }
}

@media (max-height:850px) and (min-width:701px){
    .calendar-event{
        padding:2px 6px;
        font-size:10px;
        line-height:1.15;
    }

    .event-container{
        gap:3px;
    }
}
