/* Reset and base styles */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

:root {
    --primary-color: #4a90d9;
    --primary-hover: #357abd;
    --danger-color: #dc3545;
    --danger-hover: #c82333;
    --success-color: #28a745;
    --bg-color: #f5f7fa;
    --card-bg: #ffffff;
    --text-color: #333333;
    --text-muted: #6c757d;
    --border-color: #dee2e6;
    --shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    min-height: 100vh;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 0;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 30px;
}

.navbar-brand {
    font-size: 1.5rem;
    font-weight: bold;
}

.navbar-brand a {
    color: var(--primary-color);
    text-decoration: none;
}

.navbar-brand a:hover {
    opacity: 0.8;
}

.navbar-link {
    color: var(--text-muted);
    text-decoration: none;
    padding: 5px 10px;
    border-radius: 4px;
    transition: background-color 0.2s;
}

.navbar-link:hover {
    background-color: #f0f0f0;
    color: var(--text-color);
}

.navbar-menu {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-user {
    color: var(--text-muted);
}

.logout-form {
    display: inline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 10px 20px;
    font-size: 1rem;
    font-weight: 500;
    text-align: center;
    text-decoration: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
}

.btn:active {
    transform: scale(0.98);
}

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

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

.btn-secondary {
    background-color: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background-color: #5a6268;
}

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

.btn-danger:hover {
    background-color: var(--danger-hover);
}

.btn-logout {
    background: transparent;
    color: var(--text-muted);
    padding: 5px 10px;
}

.btn-logout:hover {
    color: var(--danger-color);
}

.btn-block {
    display: block;
    width: 100%;
}

.btn-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

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

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 12px;
    font-size: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-group textarea {
    resize: vertical;
    font-family: inherit;
}

.form-hint {
    display: block;
    margin-top: 5px;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.checkbox-group input[type="checkbox"] {
    width: auto;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    margin-top: 20px;
}

/* Auth pages */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 80vh;
    padding: 20px;
}

.auth-card {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
}

.auth-title {
    text-align: center;
    margin-bottom: 30px;
    color: var(--primary-color);
}

.auth-link {
    text-align: center;
    margin-top: 20px;
    color: var(--text-muted);
}

.auth-link a {
    color: var(--primary-color);
    text-decoration: none;
}

.auth-link a:hover {
    text-decoration: underline;
}

.security-notice {
    margin-top: 25px;
    padding: 15px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #856404;
}

/* Error messages */
.error-message {
    padding: 12px;
    background-color: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 6px;
    color: #721c24;
    margin-bottom: 20px;
}

/* Diary page */
.diary-container {
    padding-bottom: 40px;
}

.diary-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
}

.diary-header h1 {
    color: var(--primary-color);
}

/* Diary list */
.diary-list {
    display: grid;
    gap: 20px;
}

.diary-card {
    background: var(--card-bg);
    padding: 20px;
    border-radius: 10px;
    box-shadow: var(--shadow);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.diary-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.15);
}

.diary-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 10px;
}

.diary-card-title {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--text-color);
    margin: 0;
}

.diary-card-date {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.diary-card-preview {
    color: var(--text-muted);
    font-size: 0.95rem;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.diary-card-actions {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid var(--border-color);
}

.diary-card-actions .btn {
    padding: 6px 12px;
    font-size: 0.9rem;
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state h3 {
    margin-bottom: 10px;
}

/* Loading state */
.loading {
    text-align: center;
    padding: 40px;
    color: var(--text-muted);
}

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

.modal-content {
    background: var(--card-bg);
    padding: 30px;
    border-radius: 12px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 450px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: var(--primary-color);
}

.modal-large {
    max-width: 700px;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h2 {
    margin-bottom: 0;
}

/* Unlock modal styles */
.unlock-header {
    text-align: center;
    margin-bottom: 25px;
}

.unlock-icon {
    font-size: 2.5rem;
    margin-bottom: 10px;
}

.unlock-header h2 {
    margin-bottom: 8px;
    color: var(--text-color);
}

.unlock-subtitle {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 0;
}

.unlock-info {
    list-style: none;
    padding: 16px 20px;
    background: linear-gradient(135deg, #f8f9fa 0%, #f1f3f4 100%);
    border-radius: 10px;
    margin-bottom: 24px;
}

.unlock-info li {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 0;
    font-size: 0.9rem;
    color: var(--text-color);
}

.unlock-info li + li {
    border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.dot-blue { background-color: #4a90d9; }
.dot-green { background-color: #28a745; }
.dot-yellow { background-color: #ffc107; }

/* Visibility toggle */
.visibility-toggle {
    padding: 15px;
    background-color: #f8f9fa;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
}

.checkbox-label input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.visibility-warning {
    margin-top: 12px;
    padding: 12px;
    background-color: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 6px;
    font-size: 0.9rem;
    color: #856404;
}

.visibility-warning code {
    background-color: rgba(0,0,0,0.1);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
}

/* Public badge */
.diary-card-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    border-radius: 4px;
    margin-left: 8px;
}

.badge-public {
    background-color: #28a745;
    color: white;
}

.badge-private {
    background-color: #6c757d;
    color: white;
}

/* Responsive */
@media (max-width: 600px) {
    .navbar {
        flex-direction: column;
        gap: 15px;
    }

    .diary-header {
        flex-direction: column;
        gap: 15px;
        align-items: stretch;
    }

    .auth-card {
        padding: 25px;
    }

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