* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --success-color: #48bb78;
    --danger-color: #f56565;
    --warning-color: #ed8936;
    --bg-dark: #1a202c;
    --bg-light: #f7fafc;
    --text-dark: #2d3748;
    --text-light: #718096;
    --border-radius: 12px;
    --shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, var(--bg-dark) 0%, #2d3748 100%);
    color: var(--text-dark);
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

.container {
    max-width: 1000px;
    margin: 0 auto;
}

/* Header */
.header {
    text-align: center;
    color: white;
    margin-bottom: 40px;
    padding: 40px 20px;
}

.header h1 {
    font-size: 3em;
    margin-bottom: 10px;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
}

.tagline {
    font-size: 1.2em;
    color: #cbd5e0;
    font-style: italic;
}

/* Counter Section */
.counter-section {
    margin-bottom: 40px;
}

.counter-card {
    background: white;
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow);
    text-align: center;
}

.counter-card h2 {
    color: var(--primary-color);
    margin-bottom: 30px;
    font-size: 1.8em;
}

.counter-display {
    display: flex;
    justify-content: space-around;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 20px;
}

.counter-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
    background: linear-gradient(135deg, var(--primary-color), #764ba2);
    border-radius: var(--border-radius);
    color: white;
    min-width: 100px;
    flex: 1;
}

.counter-number {
    font-size: 3em;
    font-weight: bold;
    line-height: 1;
    margin-bottom: 10px;
}

.counter-label {
    font-size: 0.9em;
    opacity: 0.9;
}

.sobriety-date {
    font-size: 1.1em;
    color: var(--text-light);
    margin-top: 20px;
}

.sobriety-date span {
    font-weight: bold;
    color: var(--success-color);
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-success:hover {
    background: #38a169;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
    padding: 15px 30px;
    font-size: 1.1em;
}

.btn-danger:hover {
    background: #e53e3e;
}

.btn-warning {
    background: var(--warning-color);
    color: white;
}

.btn-warning:hover {
    background: #dd6b20;
}

.btn-secondary {
    background: #cbd5e0;
    color: var(--text-dark);
}

.btn-secondary:hover {
    background: #a0aec0;
}

.btn-checkin {
    background: #edf2f7;
    color: var(--text-dark);
    border: 2px solid var(--primary-color);
    padding: 15px 30px;
    font-size: 1em;
    width: 100%;
}

.btn-checkin:hover {
    background: var(--primary-color);
    color: white;
}

.btn-tool {
    background: #f7fafc;
    color: var(--text-dark);
    border: 2px solid #cbd5e0;
    padding: 15px 20px;
}

.btn-tool:hover {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Quick Actions */
.quick-actions {
    display: flex;
    gap: 15px;
    margin-bottom: 40px;
    flex-wrap: wrap;
}

.quick-actions .btn {
    flex: 1;
    min-width: 200px;
    padding: 15px 20px;
}

/* Sections */
section {
    background: white;
    border-radius: var(--border-radius);
    padding: 30px;
    margin-bottom: 30px;
    box-shadow: var(--shadow);
}

section h3 {
    color: var(--primary-color);
    margin-bottom: 20px;
    font-size: 1.5em;
    border-bottom: 3px solid var(--primary-color);
    padding-bottom: 10px;
}

section h4 {
    color: var(--text-dark);
    margin-bottom: 15px;
    margin-top: 15px;
}

/* Check-in Section */
.checkin-options {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.check-result {
    margin-top: 20px;
    padding: 15px;
    border-radius: var(--border-radius);
    background: #f0fff4;
    border-left: 4px solid var(--success-color);
    display: none;
}

.check-result.hidden {
    display: none;
}

.check-result.show {
    display: block;
    animation: slideIn 0.3s ease;
}

/* Toolkit Section */
.toolkit-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

/* Journal Section */
.journal-input {
    margin-bottom: 25px;
}

#journalEntry {
    width: 100%;
    height: 120px;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-family: inherit;
    font-size: 1em;
    resize: vertical;
    margin-bottom: 10px;
}

#journalEntry:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.1);
}

.journal-list {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.journal-entry-item {
    background: #f7fafc;
    padding: 15px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.journal-entry-date {
    font-size: 0.85em;
    color: var(--text-light);
    margin-bottom: 8px;
}

.journal-entry-text {
    color: var(--text-dark);
    line-height: 1.5;
}

/* Stats Section */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.stat-card {
    background: linear-gradient(135deg, var(--primary-color), #764ba2);
    color: white;
    padding: 20px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

.stat-label {
    display: block;
    font-size: 0.9em;
    opacity: 0.9;
    margin-bottom: 10px;
}

.stat-number {
    display: block;
    font-size: 2.5em;
    font-weight: bold;
}

/* Resources Section */
.resources-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.resource-card {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    padding: 25px;
    border-radius: var(--border-radius);
    text-align: center;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.2);
}

.resource-card h4 {
    color: white;
    margin-bottom: 10px;
}

.resource-card p {
    margin: 8px 0;
    font-size: 1.1em;
}

.resource-info {
    font-size: 0.85em;
    opacity: 0.9;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    border-radius: var(--border-radius);
    padding: 40px;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow);
    position: relative;
}

.close-btn {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 2em;
    cursor: pointer;
    color: var(--text-light);
    transition: color 0.3s ease;
}

.close-btn:hover {
    color: var(--text-dark);
}

.modal-content h2 {
    color: var(--primary-color);
    margin-bottom: 20px;
    text-align: center;
}

/* Breathing Exercise */
.breathing-circle {
    width: 200px;
    height: 200px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-color), #764ba2);
    margin: 30px auto;
    animation: breathing 8s infinite;
    box-shadow: 0 5px 30px rgba(102, 126, 234, 0.4);
}

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

.breathing-text {
    text-align: center;
    font-size: 1.3em;
    font-weight: bold;
    color: var(--primary-color);
    margin: 20px 0;
}

/* Crisis Modal */
.crisis-modal {
    border: 3px solid var(--danger-color);
}

.crisis-message {
    font-size: 1.2em;
    color: var(--danger-color);
    margin-bottom: 30px;
    text-align: center;
}

.crisis-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin-bottom: 30px;
}

.crisis-options a {
    padding: 15px;
    border-radius: var(--border-radius);
    text-align: center;
    font-weight: bold;
    font-size: 1.1em;
}

.crisis-resources {
    background: #fff5f5;
    padding: 20px;
    border-radius: var(--border-radius);
    border: 2px solid var(--danger-color);
}

.crisis-resources h4 {
    color: var(--danger-color);
}

.crisis-resources ul {
    list-style: none;
    padding-left: 0;
}

.crisis-resources li {
    padding: 8px 0;
    color: var(--text-dark);
}

.crisis-resources li:before {
    content: "✓ ";
    color: var(--success-color);
    font-weight: bold;
    margin-right: 8px;
}

/* Distraction Ideas */
.distraction-list {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.distraction-item {
    background: #f7fafc;
    padding: 20px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--primary-color);
}

.distraction-item h4 {
    color: var(--primary-color);
    margin-top: 0;
}

/* Motivation */
.motivation-message {
    background: linear-gradient(135deg, #fef5e7, #fef9e7);
    padding: 30px;
    border-radius: var(--border-radius);
    border-left: 4px solid var(--warning-color);
    margin-bottom: 20px;
    font-size: 1.1em;
    line-height: 1.8;
    text-align: center;
    color: var(--text-dark);
}

/* Contacts */
.contact-input {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
}

.contact-input input {
    padding: 12px;
    border: 2px solid #e2e8f0;
    border-radius: var(--border-radius);
    font-size: 1em;
}

.contact-input input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.contacts-list {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 2px solid #e2e8f0;
}

.user-contact {
    background: #f7fafc;
    padding: 12px;
    border-radius: var(--border-radius);
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 10px;
}

.user-contact a {
    color: var(--primary-color);
    text-decoration: none;
    font-weight: bold;
}

.user-contact a:hover {
    text-decoration: underline;
}

.delete-contact {
    background: var(--danger-color);
    color: white;
    border: none;
    padding: 5px 10px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 0.85em;
}

.delete-contact:hover {
    background: #e53e3e;
}

/* Date Input Modal */
.date-input-section {
    margin: 20px 0;
}

#customDate {
    width: 100%;
    padding: 12px;
    font-size: 1.1em;
    border: 2px solid var(--primary-color);
    border-radius: var(--border-radius);
    cursor: pointer;
}

#customDate:focus {
    outline: none;
    box-shadow: 0 0 10px rgba(102, 126, 234, 0.3);
}

.date-helper {
    font-size: 0.9em;
    color: var(--text-light);
    margin-top: 10px;
}

#datePreview {
    font-size: 1.1em;
    text-align: center;
}

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    color: white;
    background: transparent;
    box-shadow: none;
}

.version {
    font-size: 0.85em;
    opacity: 0.8;
    margin-top: 15px;
}

/* Animations */
@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .header h1 {
        font-size: 2em;
    }

    .counter-display {
        flex-direction: column;
    }

    .quick-actions {
        flex-direction: column;
    }

    .quick-actions .btn {
        width: 100%;
    }

    .counter-card {
        padding: 20px;
    }

    section {
        padding: 20px;
    }

    .modal-content {
        padding: 20px;
        margin: 20px;
    }

    .breathing-circle {
        width: 150px;
        height: 150px;
    }
}
