:root{
    --bg:#f5f7fb;
    --card:#fff;
    --text:#172033;
    --muted:#667085;
    --border:#d9dee8;
    --blue:#2563eb;
}

*{
    box-sizing:border-box
}

body{
    margin:0;
    background:var(--bg);
    color:var(--text);
    font-family:system-ui,-apple-system,Segoe UI,Roboto,Arial
}

header{
    background:#172033;
    color:#fff;
    padding:16px 22px;
    display:flex;
    justify-content:space-between;
    align-items:center;
    gap:12px
}

h1{
    margin:0;
    font-size:22px
}

.muted,.help{
    color:var(--muted);
    font-size:13px
}

.user a{
    color:#fff
}

main{
    max-width:1250px;
    margin:auto;
    padding:18px
}

.topbar{
    display:flex;
    gap:8px;
    align-items:center;
    flex-wrap:wrap;
    margin-bottom:14px
}

.topbar b{
    font-size:19px;
    margin:0 8px
}

.button,button,select,input,textarea{
    font:inherit
}

.button,button{
    padding:9px 13px;
    border:0;
    border-radius:8px;
    cursor:pointer;
    text-decoration:none
}

.button{
    background:#e9eef5;
    color:#172033
}

.primary{
    background:var(--blue);
    color:#fff
}

.danger{
    background:#dc2626;
    color:#fff
}

.card{
    background:var(--card);
    border:1px solid var(--border);
    border-radius:12px;
    padding:16px;
    margin-bottom:16px;
    box-shadow:0 2px 12px #0000000b
}

.week,.calendar{
    display:grid;
    grid-template-columns:repeat(7,1fr)
}

.week b{
    text-align:center;
    padding:9px;
    color:var(--muted);
    border-bottom:1px solid var(--border)
}

.cell{
    min-height:125px;
    border-right:1px solid var(--border);
    border-bottom:1px solid var(--border);
    padding:6px
}

.cell:nth-child(7n){
    border-right:0
}

.num{
    font-weight:700;
    font-size:13px
}

.today{
    background:#eef5ff
}

.event{
    margin:4px 0;
    padding:5px 6px;
    border-radius:6px;
    font-size:11px;
    background:#e8eef7;
    border-left:4px solid #64748b;
    cursor:pointer;
    display:flex;
    gap:6px;
    align-items:flex-start
}

.event.soccer{
    background:#dcfce7;
    border-color:#f97316
}

.event.football{
    background:#ffedd5;
    border-color:#1d4ed8
}

.event.basketball{
    background:#ffedd5;
    border-color:#ea580c
}

.event.track{
    background:#f3e8ff;
    border-color:#7c3aed
}

.event.school{
    background:#dbeafe;
    border-color:#2563eb
}

.event.medical{
    background:#fee2e2;
    border-color:#dc2626
}

.event.pickup{
    background:#cffafe;
    border-color:#0891b2
}

.event strong{
    display:block
}

.event small{
    color:#475569;
    display:block
}

.event-logo{
    width:30px;
    height:30px;
    object-fit:contain;
    flex-shrink:0;
    border-radius:4px
}

.event-content{
    min-width:0
}

.event-content a{
    color:#2563eb;
    text-decoration:none
}

.up{
    display:flex;
    gap:12px;
    padding:10px 0;
    border-bottom:1px solid var(--border);
    cursor:pointer;
    align-items:center
}

.datebox{
    width:55px;
    text-align:center;
    flex-shrink:0
}

.datebox b{
    font-size:21px;
    display:block
}

.up-logo{
    width:42px;
    height:42px;
    object-fit:contain;
    flex-shrink:0
}

.overlay{
    display:none;
    position:fixed;
    inset:0;
    background:#0008;
    align-items:center;
    justify-content:center;
    padding:14px;
    z-index:5
}

.modal{
    background:#fff;
    border-radius:14px;
    padding:20px;
    width:min(760px,100%);
    max-height:94vh;
    overflow:auto
}

.form{
    display:grid;
    grid-template-columns:1fr 1fr;
    gap:12px
}

.form label{
    display:block;
    font-size:12px;
    font-weight:700
}

.form input,.form select,.form textarea{
    width:100%;
    margin-top:5px;
    padding:9px;
    border:1px solid var(--border);
    border-radius:7px
}

.wide{
    grid-column:1/-1
}

.form textarea{
    min-height:80px
}

.actions{
    display:flex;
    gap:8px;
    justify-content:flex-end;
    margin-top:16px
}

.auth{
    display:flex;
    justify-content:center
}

.auth .card{
    width:min(430px,100%)
}

.auth label{
    display:block;
    font-weight:700;
    font-size:13px;
    margin:12px 0
}

.auth input{
    width:100%;
    padding:10px;
    margin-top:5px;
    border:1px solid var(--border);
    border-radius:7px
}

.messages{
    max-width:1250px;
    margin:12px auto
}

.msg{
    padding:10px;
    border-radius:8px
}

.msg.error{
    background:#fee2e2
}

.msg.ok{
    background:#dcfce7
}

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

td,th{
    padding:9px;
    border-bottom:1px solid var(--border);
    text-align:left
}

.chips{
    display:flex;
    gap:6px;
    flex-wrap:wrap;
    margin-bottom:8px
}

.chips span{
    background:#eef2f7;
    border-radius:99px;
    padding:5px 8px
}

.chips form{
    margin:0
}

.x{
    padding:0 4px;
    background:transparent;
    color:#991b1b
}

.inline{
    display:flex;
    gap:8px
}

.inline input{
    flex:1;
    padding:9px;
    border:1px solid var(--border);
    border-radius:7px
}

@media(max-width:700px){

    .cell{
        min-height:90px;
        padding:4px
    }

    .event{
        font-size:9px
    }

    .event small{
        display:none
    }

    .event-logo{
        width:24px;
        height:24px
    }

    .form{
        grid-template-columns:1fr
    }

    .wide{
        grid-column:auto
    }

    .week b{
        font-size:11px;
        padding:6px
    }

    .topbar b{
        width:100%;
        text-align:center;
        order:-1
    }
}

/* ===== DARK MODE ===== */

html[data-theme="dark"]{
    --bg:#10141c;
    --card:#181e29;
    --text:#f1f5f9;
    --muted:#a8b2c1;
    --border:#303949;
    --blue:#3b82f6;
}

html[data-theme="dark"] body{
    background:var(--bg);
    color:var(--text);
}

html[data-theme="dark"] header{
    background:#080b10;
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .modal{
    background:var(--card);
    color:var(--text);
}

html[data-theme="dark"] .button{
    background:#252d3a;
    color:#f1f5f9;
}

html[data-theme="dark"] select,
html[data-theme="dark"] input,
html[data-theme="dark"] textarea{
    background:#111720;
    color:#f1f5f9;
    border-color:#3a4556;
}

html[data-theme="dark"] .event{
    background:#252d3a;
}

html[data-theme="dark"] .event.soccer{
    background:#173b2b;
}

html[data-theme="dark"] .event.football{
    background:#3b2b1b;
}

html[data-theme="dark"] .event.basketball{
    background:#3b2b1b;
}

html[data-theme="dark"] .event.track{
    background:#302346;
}

html[data-theme="dark"] .event.school{
    background:#1e3450;
}

html[data-theme="dark"] .event.medical{
    background:#452329;
}

html[data-theme="dark"] .event.pickup{
    background:#153b43;
}

html[data-theme="dark"] .cell{
    border-color:var(--border);
}

html[data-theme="dark"] .today{
    background:#172b45;
}

html[data-theme="dark"] .week b{
    color:var(--muted);
    border-color:var(--border);
}

html[data-theme="dark"] .up{
    border-color:var(--border);
}

html[data-theme="dark"] .theme-button{
    background:#252d3a;
    color:#fff;
    border:1px solid #3a4556;
}

.header-right{
    display:flex;
    align-items:center;
    gap:12px;
}

.theme-button{
    padding:8px 12px;
    border:1px solid #475569;
    border-radius:8px;
    background:#263142;
    color:#fff;
    cursor:pointer;
    font:inherit;
}

@media(max-width:700px){
    .header-right{
        flex-direction:column;
        align-items:flex-end;
        gap:6px;
    }
}

.event-title{
    display:flex;
    align-items:center;
    gap:5px;
}

.event-logo{
    width:28px;
    height:28px;
    object-fit:contain;
    flex:none;
    border-radius:4px;
}

#providerRow{
    display:none;
}

/* ===== COMPACT CALENDAR CELLS ===== */

.calendar{
    grid-auto-rows:120px;
}

.cell{
    height:120px;
    min-height:120px;
    overflow:visible;
    position:relative;
}

.event{
    position:relative;
    margin:3px 0;
    padding:4px 5px;
    height:32px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    z-index:2;
}

.event strong{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.event small{
    display:none;
}

/* ===== HOVER DETAILS ===== */

.event:hover{
    overflow:visible;
    height:auto;
    min-height:32px;
    z-index:100;
    box-shadow:0 6px 20px #0005;
}

.event:hover small{
    display:block;
    white-space:normal;
    margin-top:3px;
}

.event:hover .event-title{
    white-space:normal;
}

.event:hover::after{
    content:"";
    position:absolute;
    left:0;
    right:0;
    top:100%;
    height:8px;
}

.event-title{
    min-width:0;
}

.event-title span{
    overflow:hidden;
    text-overflow:ellipsis;
    white-space:nowrap;
}

.event:hover .event-title span{
    white-space:normal;
    overflow:visible;
}

@media(max-width:700px){

    .calendar{
        grid-auto-rows:95px;
    }

    .cell{
        height:95px;
        min-height:95px;
    }

    .event{
        height:28px;
        padding:3px 4px;
        font-size:9px;
    }

    .event-logo{
        width:22px;
        height:22px;
    }
}

/* =========================================================
   CALENDAR LAYOUT FIX
   Full width / equal columns / equal height cells
   ========================================================= */

main{
    width:100%;
    max-width:1400px;
    margin:0 auto;
}

.calendar{
    width:100%;
    display:grid;
    grid-template-columns:repeat(7,minmax(0,1fr));
    grid-auto-rows:120px;
}

.week{
    width:100%;
    display:grid;
    grid-template-columns:repeat(7,minmax(0,1fr));
}

.cell{
    width:100%;
    height:120px;
    min-height:120px;
    max-height:120px;
    overflow:visible;
    position:relative;
}

/* Keep every event compact */
.event{
    position:relative;
    height:30px;
    min-height:30px;
    max-height:30px;
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
    margin:3px 0;
    padding:4px 6px;
    z-index:3;
}

.event:hover{
    height:30px;
    min-height:30px;
    max-height:30px;
    overflow:visible;
    box-shadow:none;
}

/* Never let hover change the calendar cell */
.event:hover small{
    display:none;
}

.event-title{
    display:flex;
    align-items:center;
    gap:5px;
    min-width:0;
    height:22px;
}

.event-title span{
    overflow:hidden;
    white-space:nowrap;
    text-overflow:ellipsis;
}

.event-logo{
    width:22px;
    height:22px;
    object-fit:contain;
    flex:none;
}

/* =========================================================
   HOVER INFORMATION BOX
   ========================================================= */

.event-hover{
    display:none;
    position:absolute;
    left:0;
    top:calc(100% + 6px);
    width:330px;
    max-width:calc(100vw - 30px);
    background:#18202d;
    color:#f8fafc;
    border:1px solid #475569;
    border-radius:10px;
    padding:12px;
    box-shadow:0 12px 30px #000b;
    z-index:9999;
    white-space:normal;
    text-align:left;
}

.event:hover .event-hover{
    display:block;
}

.event-hover-title{
    font-size:15px;
    font-weight:700;
    margin-bottom:8px;
    color:#fff;
}

.event-hover-row{
    font-size:12px;
    line-height:1.45;
    margin:3px 0;
    color:#dbe4ef;
}

.event-hover-label{
    color:#94a3b8;
    font-weight:600;
}

.event-hover a{
    color:#60a5fa;
    text-decoration:none;
}

.event-hover a:hover{
    text-decoration:underline;
}

/* Don't let a hover box get clipped by the calendar card */
.card{
    overflow:visible;
}

/* Mobile: tapping still opens the event editor */
@media(max-width:700px){

    main{
        width:100%;
        max-width:none;
    }

    .calendar,
    .week{
        grid-template-columns:repeat(7,minmax(0,1fr));
    }

    .calendar{
        grid-auto-rows:95px;
    }

    .cell{
        height:95px;
        min-height:95px;
        max-height:95px;
    }

    .event{
        height:27px;
        min-height:27px;
        max-height:27px;
        padding:3px 4px;
        font-size:9px;
    }

    .event-logo{
        width:19px;
        height:19px;
    }

    .event-hover{
        display:none !important;
    }
}

/* Smart event hover popup */
.event {
    position: relative;
}

.event-hover {
    position: fixed !important;
    z-index: 99999;
    width: 340px;
    max-width: calc(100vw - 24px);
    max-height: calc(100vh - 24px);
    overflow-y: auto;
    display: none;
    left: 0;
    top: 0;
}


/* ============================================================
   SETTINGS DROPDOWN CHIPS
   Make the text clearly readable and the delete button obvious.
   ============================================================ */

.chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 8px 0 10px;
}

.chips form {
    margin: 0;
    padding: 0;
}

.chips span {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    background: #e5e7eb !important;
    color: #111827 !important;

    border: 1px solid #cbd5e1;
    border-radius: 999px;

    padding: 6px 9px 6px 12px;

    font-size: 14px;
    font-weight: 600;

    min-height: 30px;
}

.chips .x {
    display: inline-flex;
    align-items: center;
    justify-content: center;

    width: 20px;
    height: 20px;

    padding: 0;
    margin: 0;

    border: 0;
    border-radius: 50%;

    background: transparent !important;
    color: #dc2626 !important;

    font-size: 16px;
    font-weight: 800;
    line-height: 1;

    cursor: pointer;
}

.chips .x:hover {
    background: #fee2e2 !important;
    color: #991b1b !important;
}


/* Reminder Defaults settings layout */
.reminder-default-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(250px, 1fr));
    gap: 32px;
    margin: 20px 0 24px;
}

.reminder-default-column {
    min-width: 0;
}

.reminder-default-column h3 {
    margin-top: 0;
    margin-bottom: 14px;
}

.reminder-default-option {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 10px 0;
    cursor: pointer;
}

.reminder-default-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin: 0;
}

@media (max-width: 700px) {
    .reminder-default-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
}

