/* Reset and Base Styles from Narration Theme */
html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, caption, tbody, tfoot, thead, tr, th, td, article, aside, canvas, details, embed, figure, figcaption, footer, header, hgroup, menu, nav, output, ruby, section, summary, time, mark, audio, video {
    margin: 0;
    padding: 0;
    border: 0;
    font: inherit;
    font-size: 100%;
}

* {
    -webkit-box-sizing: border-box;
    -moz-box-sizing: border-box;
    box-sizing: border-box;
    outline: none;
}

body {
    background-color: #f8f8f8;
    color: #999;
    font-size: 15px;
    font-weight: 400;
    font-family: 'Playfair Display', serif;
    line-height: 1.5em;
    background-attachment: fixed;
    overflow-x: hidden;
    height: 100%;
}

a {
    color: #222;
    text-decoration: none;
    cursor: pointer;
    -webkit-transition: all 0.3s ease 0.2s;
    -moz-transition: all 0.3s ease 0.2s;
    -ms-transition: all 0.3s ease 0.2s;
    -o-transition: all 0.3s ease 0.2s;
    transition: all 0.3s ease 0.1s;
}

a:hover, a:active, a:focus {
    text-decoration: none;
    outline: 0;
    color: #000;
}

img {
    max-width: 100%;
    height: auto;
}

strong, .strong {
    font-weight: 700;
}

p {
    margin: 0 0 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    margin: 0 0 20px 0;
    color: #222;
    font-weight: 400;
    line-height: 1.5em;
    letter-spacing: .5px;
}

h1 { font-size: 32px; }
h2 { font-size: 26px; }
h3 { font-size: 20px; }
h4 { font-size: 16px; }
h5 { font-size: 14px; }
h6 { font-size: 12px; }

.uppercase {
    text-transform: uppercase;
}

.text-align-center {
    text-align: center;
}

.text-align-left {
    text-align: left;
}

.text-align-right {
    text-align: right;
}

/* Form Styles */
label {
    display: inline-block;
    margin-bottom: 5px;
    font-weight: 400;
    color: #999;
}

input, select, textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e1e5e9;
    border-radius: 0;
    font-size: 15px;
    font-family: 'Playfair Display', serif;
    transition: border-color 0.3s;
    background: #fff;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: #222;
}

input:read-only, textarea:read-only {
    background-color: #f8f9fa;
    border-color: #dee2e6;
    cursor: not-allowed;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 14px 30px;
    background: #222;
    color: #fff;
    border: none;
    font-size: 13px;
    font-weight: 700;
    font-family: 'Roboto Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
}

.btn:hover {
    background: #000;
    color: #fff;
}

.btn-secondary {
    background: #f8f8f8;
    color: #222;
    border: 1px solid #222;
}

.btn-secondary:hover {
    background: #222;
    color: #fff;
}

.btn-edit {
    background: #007bff;
    padding: 10px 20px;
    font-size: 11px;
}

.btn-edit:hover {
    background: #0056b3;
}

.btn-save {
    background: #28a745;
}

.btn-save:hover {
    background: #1e7e34;
}

.btn-cancel {
    background: #6c757d;
}

.btn-cancel:hover {
    background: #545b62;
}

/* Container and Layout */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Header Styles */
.topbar {
    background: #333;
    height: 40px;
    width: 100%;
    position: relative;
    z-index: 999;
}

.topbar .social-icons {
    margin: 0;
    list-style-type: none;
    float: left;
}

.topbar .social-icons li {
    display: inline-block;
    margin-right: 5px;
}

.topbar .social-icons a {
    color: #fff;
    line-height: 40px;
    margin-left: 10px;
    font-size: 14px;
}

.topbar .social-icons a:hover {
    opacity: .8;
    color: #fff;
}

.site-header {
    background: #fff;
    padding: 50px 0;
    text-align: center;
    position: relative;
    z-index: 996;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
}

h1.logo {
    margin-bottom: 0;
    padding: 0 20px;
    font-size: 48px;
    color: #222;
}

.logo-subtitle {
    color: #999;
    font-size: 16px;
    font-style: italic;
    margin-top: 10px;
}

/* Authentication Styles */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 40px 0;
}

.auth-card {
    background: white;
    padding: 50px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 500px;
}

/* Main Content */
.content {
    padding: 60px 0;
}

.app-container {
    display: none;
}

/* Navigation Tabs */
.nav-tabs {
    background: #fff;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    margin-bottom: 40px;
    text-align: center;
    padding: 0;
}

.nav-tab {
    display: inline-block;
    padding: 20px 30px;
    background: transparent;
    border: none;
    color: #999;
    font-size: 14px;
    font-weight: 700;
    font-family: 'Roboto Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 3px solid transparent;
}

.nav-tab:hover, .nav-tab.active {
    color: #222;
    border-bottom-color: #222;
}

/* Tab Content */
.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Post/Widget Styles */
.post, .widget, .daily-form, .card {
    background: #ffffff;
    margin-bottom: 40px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    padding: 35px;
}

.widgettitle, .card-title {
    text-transform: uppercase;
    border-left: 3px solid #222;
    margin-left: -35px;
    padding-left: 32px;
    margin-bottom: 30px;
    font-family: 'Roboto Condensed', sans-serif;
    font-weight: 700;
    letter-spacing: 2px;
    color: #222;
}

/* Form Layout */
.form-group {
    margin-bottom: 25px;
}

.form-row {
    display: flex;
    gap: 25px;
    margin-bottom: 25px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 250px;
}

.checkbox-group {
    display: flex;
    gap: 20px;
    align-items: center;
    margin-top: 10px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    margin-bottom: 0;
    cursor: pointer;
}

.checkbox-group input[type="radio"] {
    width: auto;
    margin: 0;
}

/* Mood Slider */
.mood-slider {
    width: 100%;
    margin: 15px 0;
    -webkit-appearance: none;
    height: 8px;
    background: #e1e5e9;
    outline: none;
}

.mood-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    background: #222;
    cursor: pointer;
    border-radius: 50%;
}

.mood-slider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    background: #222;
    cursor: pointer;
    border-radius: 50%;
    border: none;
}

.mood-labels {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #999;
    font-family: 'Roboto Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

#moodValue {
    font-weight: 700;
    color: #222;
}

/* Header Info */
.header-info {
    background: white;
    padding: 35px;
    margin-bottom: 40px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    text-align: center;
    position: relative;
}

.user-welcome {
    font-size: 24px;
    color: #222;
    margin-bottom: 10px;
}

.sobriety-counter {
    font-size: 48px;
    font-weight: 700;
    color: #222;
    font-family: 'Roboto Condensed', sans-serif;
    margin-bottom: 5px;
}

.sobriety-label {
    color: #999;
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Roboto Condensed', sans-serif;
}

.logout-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    background: #dc3545;
    color: white;
    border: none;
    padding: 8px 16px;
    font-size: 11px;
    font-family: 'Roboto Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    font-weight: 700;
}

.logout-btn:hover {
    background: #c82333;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 40px;
    margin-bottom: 40px;
}

/* Milestone Card */
.milestone {
    text-align: center;
    padding: 50px 35px;
    background: #222;
    color: white;
    margin-bottom: 40px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
}

.milestone h3 {
    color: white;
    font-size: 36px;
    margin-bottom: 15px;
    font-family: 'Roboto Condensed', sans-serif;
}

.milestone p {
    font-size: 16px;
    margin-bottom: 0;
    opacity: 0.8;
}

/* Chart Container */
.chart-container {
    position: relative;
    height: 300px;
    margin-top: 20px;
}

/* Quick Stats */
#quickStats p {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid #eee;
    margin-bottom: 0;
}

#quickStats p:last-child {
    border-bottom: none;
}

#quickStats span {
    font-weight: 700;
    color: #222;
}

/* Entries Browser */
.entries-browser {
    margin-bottom: 40px;
}

.date-navigation {
    background: #fff;
    padding: 25px;
    margin-bottom: 20px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
}

.date-selectors {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 20px;
    margin-bottom: 20px;
}

.entries-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 15px;
}

.entry-link {
    background: #fff;
    padding: 20px;
    border: 2px solid #e1e5e9;
    transition: all 0.3s ease;
    text-align: center;
    cursor: pointer;
}

.entry-link:hover {
    border-color: #222;
    color: #222;
    -webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
    box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
}

.entry-link.has-entry {
    background: #f8f9fa;
    border-color: #28a745;
}

.entry-link.has-entry:hover {
    border-color: #1e7e34;
}

.entry-date-display {
    font-weight: 700;
    font-family: 'Roboto Condensed', sans-serif;
    font-size: 14px;
    margin-bottom: 5px;
}

.entry-status {
    font-size: 12px;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-family: 'Roboto Condensed', sans-serif;
}

/* Entry View/Edit */
.entry-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.entry-actions {
    display: flex;
    gap: 10px;
}

/* Messages */
.success-message, .error-message {
    padding: 20px;
    margin-bottom: 25px;
    border: 1px solid transparent;
}

.success-message {
    background: #d4edda;
    color: #155724;
    border-color: #c3e6cb;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border-color: #f5c6cb;
}

/* Emergency Support */
.emergency-support {
    background: #dc3545;
    color: white;
    padding: 35px;
    margin-bottom: 40px;
    -webkit-box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
    box-shadow: 0px 0 2px rgba(0, 0, 0, 0.1);
}

.emergency-support h4 {
    color: white;
    margin-bottom: 15px;
    font-family: 'Roboto Condensed', sans-serif;
    text-transform: uppercase;
    letter-spacing: 1px;
}

.emergency-support a {
    color: white;
    text-decoration: underline;
    font-weight: bold;
}

.emergency-support a:hover {
    color: white;
    opacity: 0.8;
}

/* Resources */
.card ul {
    list-style-type: none;
    margin: 0;
}

.card ul li {
    padding: 12px 0;
    border-bottom: 1px solid #eee;
}

.card ul li:last-child {
    border-bottom: none;
}

.card ul li strong {
    color: #222;
    font-family: 'Roboto Condensed', sans-serif;
}

.card ul li a {
    color: #999;
    font-style: italic;
}

.card ul li a:hover {
    color: #222;
}

/* Daily Quote */
#dailyQuote {
    text-align: center;
    font-style: italic;
    font-size: 18px;
    line-height: 1.6em;
    color: #222;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 9999;
    display: flex;
    justify-content: center;
    align-items: center;
}

.loading-spinner {
    text-align: center;
    color: white;
}

.loading-spinner i {
    font-size: 48px;
    margin-bottom: 20px;
}

/* Responsive */
@media only screen and (max-width: 992px) {
    .form-row {
        flex-direction: column;
    }

    .form-row .form-group {
        min-width: auto;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .logout-btn {
        position: static;
        margin-top: 20px;
    }

    .header-info {
        position: relative;
    }

    .date-selectors {
        grid-template-columns: 1fr;
    }

    .entries-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }

    .entry-header {
        flex-direction: column;
        gap: 15px;
        align-items: flex-start;
    }
}

@media only screen and (max-width: 767px) {
    .auth-card {
        padding: 30px 20px;
    }

    .post, .widget, .daily-form, .card {
        padding: 25px 20px;
    }

    .widgettitle, .card-title {
        margin-left: -20px;
        padding-left: 17px;
    }

    .nav-tab {
        padding: 15px 20px;
        font-size: 12px;
    }

    .sobriety-counter {
        font-size: 36px;
    }

    .container {
        padding: 0 15px;
    }

    .checkbox-group {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .entries-grid {
        grid-template-columns: 1fr;
    }
}

/* Form Validation */
input:invalid {
    border-color: #dc3545;
}

input:valid {
    border-color: #28a745;
}

/* Loading States */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Hover Effects */
.card:hover {
    -webkit-box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
    box-shadow: 0px 2px 8px rgba(0, 0, 0, 0.15);
    transition: box-shadow 0.3s ease;
}