@import url('https://fonts.googleapis.com/css2?family=Nunito:wght@400;600;700&display=swap');

/* =========================================================
   0. GLOBALA STILREGLER
========================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* =========================================================
   APP-TEMA (ANIMATE 2.0)
========================================================= */
body {
    background: linear-gradient(135deg, #0a1f44 0%, #7eb8e6 100%);
    background-attachment: fixed; /* Håller gradienten stilla när du scrollar */
    color: #f3f4f6; /* Ljusgrå/vit text som standard */
    font-family: "Nunito", sans-serif;
    margin: 0;
    padding: 0;
    padding-bottom: 60px; /* Gör plats för bottenmenyn så den inte täcker innehåll */
    min-height: 100vh;
    -webkit-tap-highlight-color: transparent;
}

/* Snyggare rubriker mot mörk bakgrund */
h1, h2, h3, h4 {
    color: #000000;
}

.diary-h1,.diary-h2, .diary-h3, .diary-h4 {
    color: #4F46E5;
}

textarea, input, button, select {
    font-family: inherit;
    font-size: 1rem; 
    color: inherit;
}

a h1 {
    text-decoration: none !important;
}

.logo-link {
    text-decoration: none !important;
    color: inherit !important;
}

.hero {
    text-align: center;
    padding: 16px 12px;
    background: linear-gradient(135deg, #92b9d3, #CFE7F3);
    border-bottom: 4px solid #6b7daf;
    position: relative;
    width: 100%;
    border-radius: 0 0 12px 12px;
}

.hero h1 {
    font-size: clamp(2rem, 5vw, 3rem);
    color: #1d5c8f;
    letter-spacing: 0.5px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.hero h1 img {
    height: clamp(30px, 4vw, 40px);
    width: auto;
}

.tagline {
    font-size: clamp(1rem, 2.5vw, 1.2rem);
    margin-top: 6px;
    color: #1d5c8f;
}

/* =========================================================
   1. KNAPPSATS & VERKTYG (.cw-btn)
========================================================= */
.cw-btn {
    width: 100%;
    min-height: 42px;
    padding: 10px 14px;
    margin-top: 10px;
    border-radius: 12px;
    border: none;
    background: #F2F2F2;
    color: #333333;
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.cw-btn:hover { background: #E6E6E6; }
.cw-btn:active { transform: scale(0.98); }

.cw-yellow { background: #FFF7C2; color: #554800; }
.cw-yellow:hover { background: #FFEF9A; }
.cw-green { background: #D8F5D0; color: #1E5016; }
.cw-green:hover { background: #C4ECB9; }
.cw-blue { background: #D7E8FF; color: #143A66; }
.cw-blue:hover { background: #C3D9FF; }
.cw-edit { background: #D8F5D0; color: #1E5016; }
.cw-edit:hover { background: #C4ECB9; }
.cw-delete { background: #FFD6D6; color: #7A1C1C; }
.cw-delete:hover { background: #FFB3B3; }
.cw-galleri { background: #F3E5F5; color: #7A1C1C; }
.cw-galleri:hover { background: #edcff1; }

.cw-auto {
    width: auto;
    display: inline-flex;
    background: #F3E5F5;
}
.cw-auto:hover { background: #edcff1; }

.cw-btn-row {
    display: flex;
    gap: 10px;
}
.cw-btn-row .cw-btn {
    flex: 1;
    margin-top: 10px;
}

/* =========================================================
   2. SPARA & KNAPPAR INUTI MODALER
========================================================= */
.edit-buttons {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.save-btn, .modal-save-btn {
    width: 100%;
    min-height: 44px;
    padding: 10px 16px;
    border: none;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 600;
    background: #D8F5D0;
    color: #1E5016;
    cursor: pointer;
    margin-top: 8px;
    box-shadow: 0 2px 6px rgba(76, 175, 80, 0.25);
    transition: background 0.2s ease, transform 0.1s ease;
}

.save-btn:hover, .modal-save-btn:hover { background: #C4ECB9; }
.save-btn:active, .modal-save-btn:active { transform: scale(0.98); }
.modal-edit .modal-save-btn { background: #4CAF50; }

/* =========================================================
   3. GRID & LAYOUT (CodaWorks Standard)
========================================================= */
.cw-row {
    display: flex;
    gap: 15px;
    width: 100%;
}
.cw-col {
    flex: 1; 
    min-width: 0;       /* Hindrar innehåll från att tvinga kolumnen att bli för bred */
    max-width: 100%;    /* Säkerställer att den aldrig går utanför pappan */
}

@media (max-width: 480px) {
    .cw-row {
        flex-direction: column;
        gap: 0;
    }
}

/* =========================================================
   4. FORMULÄR & INMATNINGSFÄLT
========================================================= */
.cw-form-group {
    margin-bottom: 16px;
}

.cw-label {
    display: block;
    font-weight: 600;
    margin-bottom: 6px;
    color: #2F4F3A;
    font-size: 0.95rem;
}

.cw-input, .cw-select, .cw-textarea {
    width: 100%;
    padding: 8px 14px !important; 
    border-radius: 12px !important; 
    border: 1px solid #D1D9D4;
    font-size: 1rem;
    font-family: inherit;
    background-color: #FFFFFF;
    color: #333333 !important;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    overflow-y: auto;
}

.cw-input:focus, .cw-select:focus, .cw-textarea:focus {
    outline: none;
    border-color: #4F8F5A; 
    box-shadow: 0 0 0 3px rgba(79, 143, 90, 0.2); 
}

.cw-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%232F4F3A%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
    background-repeat: no-repeat;
    background-position: right 14px top 50%;
    background-size: 12px auto;
    padding-right: 40px !important;
    color: #333333 !important;
}

/* Gör så att alla formulärfält får samma färg när man klickar i dem */
input:focus, 
textarea:focus, 
select:focus {
    outline: none !important; /* Tar bort webbläsarens fula standard-markering */
    border-color: #3b82f6 !important; /* Byt ut #3b82f6 mot den hex-kod du vill ha (detta är den snygga blåa) */
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2) !important; /* Ger en mjuk "glöd" runt fältet i samma färg */
}

/* =========================================================
   5. TOAST MEDDELANDEN
========================================================= */
#cw-toast-container {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 9999999 !important; 
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none; 
    width: 90%;
    max-width: 350px;
    align-items: center;
}

.cw-toast {
    background-color: #333; 
    color: #fff;
    padding: 12px 24px;
    border-radius: 50px; 
    font-size: 0.95rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55); 
}

.cw-toast.show {
    opacity: 1;
    transform: translateY(0);
}
.cw-toast.success { background-color: #4338CA; }
.cw-toast.error { background-color: #ff5a4e; }
.cw-toast.info { background-color: #2F4F3A; } 

/* =========================================================
   6. KORT (CARDS) & GRID 
========================================================= */
/* =========================================================
   6. HORISONTELL SWIPE FÖR DJURKORTEN
========================================================= */
.cw-card-grid {
    display: flex;
    flex-wrap: nowrap; /* Tvingar korten att stanna på en och samma rad */
    gap: 12px;
    overflow-x: auto;  /* Aktiverar horisontell scroll */
    padding-bottom: 10px; /* Luft så att scrollbaren inte klipper korten */
    -webkit-overflow-scrolling: touch; /* Ger det där mjuka "flytet" på iPhone */
    
    /* Gömmer själva scrollbaren för en renare "app-känsla" */
    scrollbar-width: none; /* Firefox */
}
.cw-card-grid::-webkit-scrollbar {
    display: none; /* Chrome, Safari och Edge */
}

/* Tvinga korten inuti att hålla sin form och inte krympa ihop */
.cw-card-grid > div { /* Eller .cw-card om korten har den klassen */
    flex: 0 0 auto; 
    width: 350px; /* Justera bredden på korten här! */
    /* Du kan också använda typ 80vw på mobil så kortet tar nästan hela skärmen */
}

.cw-card {
    background: #ffffff;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-top: 4px solid #0056b3; 
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    cursor: pointer;
}

.cw-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.cw-card-img-container {
    width: 100%;
    height: 180px;
    background-color: #f0f4f8; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 4rem; 
}

.cw-card-img {
    width: 100%;
    height: 100%;
    object-fit: cover; 
}

.cw-card-content { padding: 16px; }
.cw-card-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: #333;
    margin: 0 0 8px 0;
}
.cw-card-subtitle {
    font-size: 0.9rem;
    color: #666;
    margin: 0 0 12px 0;
}

.cw-badge-blue {
    display: inline-block;
    background: #e6f4ea;
    color: #2c5e3b;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
}

@media (max-width: 768px) {
    .cw-card-grid { grid-template-columns: 1fr !important; }
}

/* =========================================================
   7. FILUPPLADDNINGS-KNAPP
========================================================= */
.cw-btn-file {
    display: flex !important;
    align-items: center;
    justify-content: flex-start; 
    padding: 6px 14px !important; 
    border-radius: 12px !important;
    margin: 0 !important; 
    font-size: 1rem !important;
    font-weight: 400 !important; 
    line-height: normal !important; 
    background-color: #e3f2fd;
    color: #0056b3;
    border: 1px solid #b6d4fe;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.cw-btn-file:hover {
    background-color: #cce5ff;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.05);
}

/* =========================================================
   8. KOMPAKTA LIST-KORT
========================================================= */
.cw-list-card {
    display: flex;
    align-items: center;
    gap: 16px; 
    background: #ffffff;
    border-radius: 12px;
    padding: 14px 16px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.05);
    border-left: 4px solid #0056b3; 
    cursor: pointer;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cw-list-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.1);
}

.cw-list-img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    overflow: hidden;
    background-color: #f0f4f8;
    flex-shrink: 0; 
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem; 
}
.cw-list-img img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.cw-list-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.cw-list-content .cw-card-title {
    margin: 0 0 2px 0; 
    font-size: 1.15rem;
    font-weight: 700;
    color: #111827;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-list-content .cw-card-subtitle {
    margin: 0 0 8px 0; 
    font-size: 0.85rem;
    color: #6B7280;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.cw-list-status {
    display: flex;
    align-items: center;
}

/* =========================================================
   9. ACCORDION STYLING
========================================================= */
.cw-accordion {
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 8px;
    overflow: hidden;
    text-align: left !important;
    width: 100%;
    box-sizing: border-box;
}

.cw-accordion-header {
    padding: 12px 16px;
    background: #f8fafc;
    font-weight: 600;
    color: #1e293b;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    list-style: none; 
    text-align: left; 
}

.cw-accordion-header::after {
    content: '▼';
    font-size: 0.8rem;
    color: #64748b;
    transition: transform 0.2s ease-in-out;
}
.cw-accordion[open] .cw-accordion-header::after {
    transform: rotate(180deg);
}
.cw-accordion-header::-webkit-details-marker {
    display: none;
}

.cw-accordion-body {
    padding: 16px;
    border-top: 1px solid #e2e8f0;
    color: #475569;
    font-size: 0.95rem;
    text-align: left !important;
}

/* =========================================================
   10. NOTIFIKATIONER & MEDDELANDE-OVERLAY
========================================================= */
.msg-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease;
}
.msg-overlay.show {
    opacity: 1;
    pointer-events: auto;
}
.msg-overlay.hidden { display: none; }

.msg-box {
    background: #FFFFFF;
    padding: 24px 28px;
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.2);
    width: 90%;
    max-width: 380px;
    text-align: center;
    transform: translateY(15px);
    transition: transform 0.25s ease;
}
.msg-overlay.show .msg-box { transform: translateY(0); }

.msg-icon { font-size: 2rem; margin-bottom: 10px; }
.msg-text {
    font-size: 1.05rem;
    color: #2F4F3A;
    margin-bottom: 20px;
    line-height: 1.4;
}
.msg-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
}

/* =========================================================
   11. INLOGGNINGSSIDAN
========================================================= */
.login-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background: #F7F9F8;
    padding: 20px;
}
.login-container { animation: modalFadeIn 0.3s ease-out; }

@keyframes modalFadeIn {
    from { opacity: 0; transform: scale(0.96) translateY(8px); }
    to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Ser till att Flatpickr-kalendern alltid ligger överst (över modaler/dialoger) */
.flatpickr-calendar {
    z-index: 99999 !important;
}