/* =============================================
   Radi-Cal Notes Unified Styles
   Single source of truth for all pages
   ============================================= */

:root {
    --yellow: #fff9b1;
    --shadow: 0 10px 30px rgba(0,0,0,0.25), 8px 8px 0 rgba(0,0,0,0.1);
}

/* Base reset & typography */
* {
    box-sizing: border-box;
}

html, body {
    min-height: 100%;
    margin: 0;
    padding: 0;
    background: linear-gradient(180deg, #f0f0f0 0%, #d8d8d8 100%);
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.45;
    overflow-y: auto;
    overscroll-behavior-y: contain;
}

/* Container & Sticky Note - Common foundation */
.container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/*
.sticky-note {
    width: 100%;
    max-width: 480px;
    min-height: 85vh;
    background: var(--yellow);
    box-shadow: var(--shadow);
    border-radius: 4px;
    padding: 40px 35px 45px;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: rotate(-1deg);
    transition: transform 0.2s ease;
    overflow: visible;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
*/

/* UPDATE TO MAKE STICKY NOTE CONTENTS SCROLLABLE */
/**************************************************/
.sticky-note {
    width: 100%;
    max-width: 480px;
    min-height: 85vh;
    margin-bottom: 10vh;
    background: var(--yellow);
    box-shadow: var(--shadow);
    border-radius: 4px;
    padding: 40px 35px 45px;
    position: relative;
    display: flex;
    flex-direction: column;
    transform: rotate(-1deg);
    transition: transform 0.2s ease;

    /* NEW: Enable proper scrolling */
    max-height: 100vh;           /* Crucial on mobile */
    overflow: hidden;            /* Hide overflow on the container */
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}
/**************************************************/

.sticky-note:hover {
    transform: rotate(0deg);
}

.sticky-note::before {
    content: '';
    position: absolute;
    top: -12px;
    left: 50%;
    transform: translateX(-50%);
    width: 120px;
    height: 28px;
    background: #f8d7d7;
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
    z-index: 2;
    border-radius: 4px;
}

.title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 20px 0;
    color: #2c2c2c;
    text-align: center;
    line-height: 1.1;
    letter-spacing: -0.015em;
}

/* Button styling - consistent across all pages */
button {
    background: #ffcc00;
    color: #222;
    border: none;
    border-radius: 12px;
    padding: 16px 24px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1.4rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 6px 0 #cc9900, 0 8px 20px rgba(0,0,0,0.3);
    transition: all 0.2s ease;
}

button:active {
    transform: translateY(4px);
    box-shadow: 0 2px 0 #cc9900, 0 4px 10px rgba(0,0,0,0.3);
}

button.green {
    background: #27ae60;
    color: white;
    box-shadow: 0 6px 0 #1e8c4e;
}

button.green:active {
    box-shadow: 0 2px 0 #1e8c4e;
}

button.full-width {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Common utility classes */
.status {
    text-align: center;
    font-size: 1.35rem;
    padding: 12px;
    border-radius: 12px;
    min-height: 60px;
}

.success {
    background: #d4edda;
    color: #155724;
}

/* Page-specific overrides (kept minimal) */

 /* index.html specific */
#note-display {
    flex: 1;
    padding: 8px;
    font-size: 1.38rem;
    line-height: 1.45;
    color: #222;
    white-space: pre-wrap;
    overflow-y: auto;
}

#map-container {
    margin-top: 20px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
    flex-shrink: 0;
    position: relative;
    height: 250px;
}

/* write.html specific */
.scrollable-content {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #ccc #fff9b1;
    min-height: 0;
}

.scrollable-content::-webkit-scrollbar {
    width: 6px;
}

.scrollable-content::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 10px;
}

.form-container {
    background: white;
    border: 1px dotted #666;
    border-radius: 1.2vmax;
    padding: 28px 22px;
    box-shadow: inset 0 2px 6px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
    gap: 26px;
}

.note-wrapper {
    position: relative;
}

textarea {
    width: 100%;
    padding: 16px 18px 48px 18px;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
    font-size: 1.48rem;
    border: 2px dashed #666;
    border-radius: 10px;
    background: #fff9e6;
    resize: vertical;
    min-height: 160px;
    line-height: 1.45;
}

.char-counter {
    position: absolute;
    bottom: 16px;
    right: 18px;
    font-size: 1.2rem;
    padding: 3px 12px;
    border-radius: 12px;
    background: rgba(255,255,255,0.92);
    pointer-events: none;
}

/* view.html specific */
.history-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 10px;
    scrollbar-width: thin;
    scrollbar-color: #ccc #fff9b1;
}

.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

.history-item {
    background: white;
    border: 2px dashed #666;
    border-radius: 12px;
    padding: 18px;
    margin-bottom: 14px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.history-item:hover {
    background: #fff9e6;
    transform: scale(1.02);
}

.history-item strong {
    font-size: 1.45rem;
    color: #222;
    font-weight: 700;
}

.history-date {
    font-size: 1.1rem;
    color: #666;
    margin: 4px 0 10px 0;
}

.no-history, .filter-info {
    text-align: center;
    color: #666;
}

/* sync_QR.html specific */
.qr-container {
    background: white;
    padding: 20px;
    border: 4px solid #222;
    border-radius: 12px;
    text-align: center;
    min-height: 300px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scanner {
    width: 100%;
    /*max-width: 320px;*/
    margin: 0 auto;
    border: 4px solid #222;
    border-radius: 12px;
    overflow: hidden;
}

video {
    width: 100%;
    display: block;
}

.back-btn {
    position: absolute;
    top: 5px;
    left: 5px;
    background: #fff;
    color: #222;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    font-size: 28px;
    line-height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    z-index: 10;
}

.chunk-info {
    font-size: 1.3rem;
    font-weight: 700;
    color: #222;
    margin-top: 10px;
}

/* Toast & NFC (used in write.html) */
.toast {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #222;
    color: white;
    padding: 16px 26px;
    border-radius: 14px;
    font-size: 1.28rem;
    box-shadow: 0 12px 35px rgba(0,0,0,0.45);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s ease;
    pointer-events: none;
    text-align: center;
    max-width: 340px;
    line-height: 1.45;
}

.toast.show {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

#nfc-overlay {
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: rgba(0,0,0,0.78);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    flex-direction: column;
    color: white;
    font-size: 1.45rem;
    text-align: center;
}

.nfc-icon {
    font-size: 5.8rem;
    margin-bottom: 20px;
    animation: pulse 1.8s infinite;
}
.scanning-on-btn {
    animation: pulse 1.8s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.12); }
}

/* Responsive */
@media (max-width: 360px) {
    .sticky-note { padding: 30px 25px 25px; }
    .title { font-size: 1.98rem; }
    textarea { font-size: 1.38rem; min-height: 145px; }
}

.clickable-title {
    cursor: pointer;
    text-decoration: underline;
    color: #2c2c2c;
    transition: color 0.2s ease;
}

.clickable-title:hover {
    color: #27ae60;
}

.clickable-title:active {
    color: #1e8c4e;
}


/* UPDATE TO MAKE STICKY NOTE CONTENTS SCROLLABLE */
/* Make all main content areas reliably scrollable */
/**************************************************/
.sticky-note > .content,
.sticky-note > .scrollable-content,
#note-display,
.history-list {
    flex: 1 1 auto;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;     /* Smooth momentum scrolling on iOS/Android */
    overscroll-behavior-y: contain;        /* Prevents pull-to-refresh conflicts */
}

/* Extra safety for index.html note display */
#note-display {
    max-height: none;   /* Let flex handle it */
    padding-bottom: 8px; /* Breathing room at bottom */
}
/**************************************************/

#map-container {
    flex-shrink: 0 !important;
    overflow: visible !important;
    max-height: none !important;
}

.sticky-note {
    overflow-y: auto !important;   /* Tärkein korjaus */
    max-height: none !important;
}

#offline-map img {
    box-shadow: 0 0 0 1px rgba(0,0,0,0.2);
}