/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: Arial, sans-serif;
    background: #f0f2f5;
    color: #222;
    font-size: 14px;
    -webkit-text-size-adjust: 100%;
    overflow-x: hidden;
}

/* ── Navbar ── */
.navbar {
    position: sticky;
    top: 0;
    z-index: 100;
    background: #f0f2f5;
}
.navbar-inner {
    max-width: 1200px;
    margin: 0 auto;
    padding: 8px 12px;
    display: flex;
    flex-direction: column;
    background: #1a6fc4;
    border-radius: 0 0 10px 10px;
}
.navbar-brand {
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    text-decoration: none;
    white-space: nowrap;
    text-align: center;
    padding-bottom: 6px;
}
.navbar-links {
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.navbar-links a { color: #fff; text-decoration: none; font-size: 13px; opacity: 0.9; white-space: nowrap; }
.navbar-links a:hover { opacity: 1; text-decoration: underline; }
.navbar-links a.danger { color: #ffaaaa; }
.navbar-links-left  { display: flex; gap: 12px; align-items: center; }
.navbar-links-right { display: flex; gap: 12px; align-items: center; }

/* ── Search bar ── */
.search-bar { margin-bottom: 16px; }
.search-bar form { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.search-bar input {
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    flex: 1;
    min-width: 140px;
    max-width: 300px;
}

/* ── Page wrapper ── */
.page { max-width: 1200px; margin: 16px auto; padding: 0 12px; }

/* ── Card ── */
.card {
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 1px 4px rgba(0,0,0,.1);
    padding: 16px;
    margin-bottom: 16px;
}
.card h2 { font-size: 14px; color: #333; margin-bottom: 12px; }

/* ── Flash messages ── */
.msg-success { color: #1a7a3a; background: #e6f4ea; border-radius: 5px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }
.msg-error   { color: #b00020; background: #fdecea; border-radius: 5px; padding: 8px 12px; margin-bottom: 12px; font-size: 13px; }

/* ── Forms ── */
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; color: #666; margin-bottom: 4px; }
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 14px;
    font-family: Arial, sans-serif;
    background: #fafafa;
    transition: border-color .2s;
    -webkit-appearance: none;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { outline: none; border-color: #1a6fc4; background: #fff; }
input[type="password"]::placeholder { color: #ccc; }

/* ── Buttons ── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    font-family: Arial, sans-serif;
    transition: background .2s;
    white-space: nowrap;
    touch-action: manipulation;
}
.btn-primary  { background: #1a6fc4; color: #fff; }
.btn-primary:hover  { background: #155a9e; }
.btn-danger   { background: #e74c3c; color: #fff; }
.btn-danger:hover   { background: #c0392b; }
.btn-dark     { background: #555; color: #fff; }
.btn-dark:hover     { background: #333; }
.btn-outline  { background: #fff; color: #1a6fc4; border: 1px solid #1a6fc4; }
.btn-outline:hover  { background: #e8f0fb; }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
input:disabled { opacity: 0.45; cursor: not-allowed; background: #eee; }

/* ── Upload block ── */
.upload-row { display: flex; gap: 12px; flex-wrap: wrap; }
.upload-row .form-group { flex: 1; min-width: 130px; }
.upload-audio-row { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; flex-wrap: wrap; }
.audio-status { font-size: 12px; color: #888; }

/* ── Client note card ── */
.client-note-card {
    border: none;
    border-radius: 12px;
    background: linear-gradient(135deg, #e8f0fb 0%, #f5f9fc 100%);
    padding: 0;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(26, 111, 196, 0.1);
}
.client-note-form {
    display: flex;
    gap: 0;
    align-items: stretch;
}
.client-note-textarea {
    flex: 1;
    padding: 8px 12px;
    border: none;
    border-radius: 0;
    font-size: 14px;
    font-family: Arial, sans-serif;
    background: transparent;
    resize: none;
    min-height: 36px;
    max-height: 80px;
    color: #222;
}
.client-note-textarea::placeholder {
    color: #888;
}
.client-note-textarea:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.7);
}
.btn-save-note {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: #4a90d9;
    color: #fff;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: all .2s;
    box-shadow: 0 1px 3px rgba(74, 144, 217, 0.3);
}
.btn-save-note:hover {
    background: #3a7bc8;
    transform: translateY(-1px);
    box-shadow: 0 2px 4px rgba(74, 144, 217, 0.4);
}
.btn-save-note:active {
    transform: translateY(0);
    box-shadow: 0 1px 2px rgba(74, 144, 217, 0.3);
}

/* ── Year nav ── */
.year-nav { display: flex; justify-content: center; align-items: center; gap: 12px; margin-bottom: 16px; }
.year-nav span { font-size: 15px; font-weight: bold; color: #333; }

/* ── Calendar ── */
.calendar-wrap { display: flex; gap: 16px; flex-wrap: wrap; }
.calendar-table {
    border-collapse: collapse;
    width: 200px;
    margin-bottom: 16px;
    font-size: 12px;
}
.calendar-table th, .calendar-table td {
    border: 1px solid #ddd;
    padding: 4px;
    text-align: center;
    position: relative;
    vertical-align: middle;
}
.calendar-table th { background: #e8f0fb; color: #1a6fc4; }
.calendar-table td { cursor: pointer; }
.calendar-table td:not(.has-photo):hover { background: #e8f0fb; }
.has-photo, .has-note { background: #1a6fc4; color: #fff; }
.has-refused  { background: #e74c3c !important; color: #fff !important; }
.has-postponed { background: #f39c12 !important; color: #fff !important; }
.has-photo.today, .has-note.today { background: #c2d8f5; color: #1a6fc4; box-shadow: inset 0 0 0 2px #1a6fc4; }
.has-birthday { box-shadow: inset 0 0 0 2px #e74c3c; }
.has-birthday.has-photo, .has-birthday.has-note { box-shadow: inset 0 0 0 2px #e74c3c, inset 0 0 0 4px #1a6fc4; }
.has-birthday.today { box-shadow: inset 0 0 0 2px #e74c3c; }
.has-birthday.today.has-photo, .has-birthday.today.has-note { box-shadow: inset 0 0 0 2px #e74c3c, inset 0 0 0 4px #1a6fc4; }
.today    { background: #c2d8f5; font-weight: bold; color: #1a6fc4; }
.weekend  { color: #e74c3c; }
.selected { box-shadow: inset 0 0 0 3px #27ae60; }
.has-photo.selected, .has-note.selected { background: #1a6fc4; color: #fff; box-shadow: inset 0 0 0 3px #27ae60; }

/* ── Tooltip ── */
.photo-preview-tooltip {
    display: none;
    position: fixed;
    background: rgba(25,25,35,.96);
    padding: 10px;
    border-radius: 10px;
    z-index: 9999;
    white-space: normal;
    box-shadow: 0 6px 24px rgba(0,0,0,.4);
    flex-direction: column;
    gap: 8px;
    width: 80vw;
    max-height: 60vh;
    overflow: hidden;
    pointer-events: auto;
}
.tp-scroll {
    display: flex;
    flex-direction: column !important;
    gap: 8px;
    overflow-x: hidden;
    overflow-y: auto;
    width: 100%;
    max-height: calc(60vh - 50px);
    scrollbar-width: none;
}
.tp-scroll::-webkit-scrollbar { display: none; }
.tp-close {
    display: block;
    align-self: flex-end;
    background: #e74c3c;
    color: #fff;
    border-radius: 50%;
    width: 22px;
    height: 22px;
    font-size: 14px;
    line-height: 22px;
    text-align: center;
    cursor: pointer;
    z-index: 10001;
    flex-shrink: 0;
    box-shadow: 0 2px 6px rgba(0,0,0,.5);
}
.tp-item {
    display: block;
    width: 100%;
    flex-shrink: 0;
}
.tp-img-wrap { position: relative; width: 100%; display: block; }
.tp-img-wrap img {
    width: 100%;
    height: auto !important;
    max-height: none !important;
    border-radius: 6px;
    cursor: pointer;
    display: block;
}
.tp-btn {
    position: absolute;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    font-size: 11px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
    z-index: 10;
    color: #fff;
}
.tp-btn-delete { top: 3px; left: 3px;  background: #e74c3c; }
.tp-btn-edit   { bottom: 3px; left: 3px; background: #1a6fc4; }
.tp-note {
    width: 100%;
    font-size: 12px;
    color: #ccc;
    margin-top: 5px;
    word-break: break-word;
    overflow-wrap: anywhere;
    text-align: left;
    max-height: 120px;
    overflow-y: auto;
}
.tp-audio-wrap {
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 60px;
    background: rgba(255,255,255,.08);
    border-radius: 6px;
    gap: 8px;
    padding: 10px;
    cursor: pointer;
    user-select: none;
}
.tp-audio-wrap:hover { background: rgba(255,255,255,.15); }
.tp-audio-icon { font-size: 26px; }
.tp-audio-playing .tp-audio-icon::after { content: ' ▐▐'; font-size: 12px; }
.tp-audio-status { font-size: 10px; color: #aaa; text-align: center; word-break: break-word; }
.photo-note { display: none; }

/* ── Auth / Profile card ── */
.auth-card, .profile-card {
    max-width: 380px;
    margin: 40px auto;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 2px 12px rgba(0,0,0,.1);
    padding: 28px;
}
.auth-card h2, .profile-card h2 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 18px;
    color: #1a6fc4;
}
.auth-switch { text-align: center; margin-top: 14px; font-size: 13px; color: #666; }
.auth-switch a { color: #1a6fc4; cursor: pointer; text-decoration: underline; }
.back-link { display: block; text-align: center; margin-top: 14px; font-size: 13px; color: #1a6fc4; text-decoration: none; }
.back-link:hover { text-decoration: underline; }

/* ── Mobile ── */
@media (max-width: 600px) {
    body { font-size: 13px; }

    .navbar { padding: 6px 12px; }
    .navbar-brand { font-size: 14px; }
    .navbar-links-left, .navbar-links-right { gap: 8px; }
    .navbar-links a { font-size: 12px; }

    .page { margin: 10px auto; padding: 0 8px; }
    .card { padding: 12px; }

    .search-bar input { max-width: 100%; }

    .upload-row { flex-direction: column; gap: 0; }
    .upload-row .form-group { min-width: 100%; }

    .calendar-table { width: 100%; font-size: 11px; }
    .calendar-table th, .calendar-table td { padding: 3px 2px; }

    .year-nav { gap: 8px; }
    .year-nav span { font-size: 14px; }

    .auth-card, .profile-card { margin: 16px auto; padding: 20px 16px; }

    .btn { padding: 9px 14px; font-size: 13px; }

    .photo-preview-tooltip { max-width: calc(100vw - 16px); width: 90vw; }
    .tp-item { width: 100%; }
    .tp-img-wrap { width: 100%; }
    .tp-img-wrap img { width: 100%; height: auto; }
    .tp-audio-wrap { width: 100%; min-height: 60px; }
    .tp-note { width: 100%; }
}

