/* CSS Reset & Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #667eea;
    --primary-dark: #764ba2;
    --primary-hover: #5568d3;
    --success-color: #48bb78;
    --error-color: #f56565;
    --warning-color: #ed8936;
    --info-color: #4299e1;
    --text-color: #333;
    --text-light: #666;
    --text-lighter: #999;
    --bg-color: #f5f5f5;
    --bg-light: #fafafa;
    --white: #ffffff;
    --border-color: #e0e0e0;
    --border-radius: 5px;
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.1);
    --transition: all 0.2s ease;
}

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

main {
    flex: 1;
}

/* Container */
.container {
    max-width: 800px;
    margin: 0 auto;
    padding: 20px;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    line-height: 1.2;
    margin-bottom: 1rem;
    font-weight: 600;
}

h1 {
    font-size: 2rem;
    color: var(--text-color);
}

h2 {
    font-size: 1.5rem;
    color: var(--text-light);
}

h3 {
    font-size: 1.25rem;
    color: var(--text-color);
}

p {
    margin-bottom: 1rem;
}

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

.text-small {
    font-size: 0.875rem;
}

/* Links */
a {
    color: var(--primary-color);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* Buttons */
.btn {
    display: inline-block;
    padding: 8px 15px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: 3px;
    cursor: pointer;
    font-size: 1rem;
    text-decoration: none;
}

.btn:hover {
    background: #e6f2ff;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    font-weight: bold;
    border: none;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-link {
    background: none;
    border: none;
    color: var(--primary-color);
    cursor: pointer;
    padding: 0;
    font-size: inherit;
}

.btn-link:hover {
    text-decoration: underline;
}

/* Navigation */
.navbar {
    background: var(--white);
    border-bottom: 1px solid var(--border-color);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.nav-brand a {
    font-size: 1.25rem;
    font-weight: bold;
    color: var(--primary-color);
    text-decoration: none;
}

.nav-brand a:hover {
    text-decoration: none;
    opacity: 0.8;
}

.nav-toggle {
    display: none;
    flex-direction: column;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    gap: 4px;
}

.nav-toggle span {
    display: block;
    width: 25px;
    height: 3px;
    background: var(--text-color);
    transition: var(--transition);
    border-radius: 2px;
}

.nav-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(5px, 5px);
}

.nav-toggle.active span:nth-child(2) {
    opacity: 0;
}

.nav-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -6px);
}

.nav-menu {
    display: flex;
    gap: 1.5rem;
    align-items: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 500;
    padding: 0.5rem 0.75rem;
    border-radius: var(--border-radius);
    transition: var(--transition);
}

.nav-link:hover {
    background: var(--bg-color);
    text-decoration: none;
}

.nav-link.active {
    color: var(--primary-color);
    background: var(--bg-light);
}

.nav-user-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-user {
    color: var(--text-light);
    font-size: 0.9rem;
}

.nav-logout-form {
    display: inline;
    margin: 0;
}

.nav-login-btn {
    margin-left: 0.5rem;
}

/* User Dropdown Menu */
.nav-user-dropdown {
    position: relative;
}

.nav-user-button {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: var(--transition);
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-color);
}

.nav-user-button:hover {
    background: var(--bg-light);
    border-color: var(--primary-color);
}

.nav-user-button:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.nav-user-greeting {
    font-weight: 500;
}

.nav-user-chevron {
    transition: transform 0.2s ease;
    color: var(--text-light);
}

.nav-user-button[aria-expanded="true"] .nav-user-chevron {
    transform: rotate(180deg);
}

.nav-user-menu {
    position: absolute;
    top: calc(100% + 0.5rem);
    right: 0;
    min-width: 220px;
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow-lg);
    padding: 0.5rem 0;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    z-index: 1000;
}

.nav-user-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.nav-user-menu-header {
    padding: 0.75rem 1rem;
}

.nav-user-menu-name {
    font-weight: 600;
    color: var(--text-color);
    margin-bottom: 0.25rem;
}

.nav-user-menu-email {
    font-size: 0.875rem;
    color: var(--text-light);
}

.nav-user-menu-divider {
    height: 1px;
    background: var(--border-color);
    margin: 0.5rem 0;
}

.nav-user-menu-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    background: none;
    border: none;
    color: var(--text-color);
    font-family: inherit;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
    text-align: left;
}

.nav-user-menu-item:hover {
    background: var(--bg-light);
    color: var(--primary-color);
}

.nav-user-menu-item svg {
    flex-shrink: 0;
    opacity: 0.7;
}

/* Cards & Sections */
.card {
    background: var(--white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    margin-bottom: 1.5rem;
}

.card-header {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}

.card-title {
    margin: 0;
    font-size: 1.25rem;
}

.section {
    margin: 30px 0;
    padding: 20px;
    background: var(--bg-color);
    border-radius: var(--border-radius);
}

/* Forms */
.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-color);
    font-weight: 500;
    font-size: 0.95rem;
}

input[type="text"],
input[type="email"],
input[type="password"],
textarea,
select {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius);
    font-size: 1rem;
    font-family: inherit;
    transition: var(--transition);
    background-color: var(--white);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

input[type="text"]:disabled,
input[type="email"]:disabled,
input[type="password"]:disabled,
textarea:disabled,
select:disabled {
    background-color: var(--bg-color);
    cursor: not-allowed;
    opacity: 0.6;
}

textarea {
    min-height: 100px;
    resize: vertical;
}

.form-help {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-light);
}

.form-error {
    display: block;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: var(--error-color);
}

/* Lists */
ul {
    list-style-type: none;
    padding: 0;
}

li {
    margin: 10px 0;
}

/* Code */
code {
    background: var(--white);
    padding: 2px 5px;
    border-radius: 3px;
    font-size: 0.9em;
    font-family: "Courier New", monospace;
}

/* Flash Messages */
.flash {
    padding: 12px 20px;
    border-radius: 5px;
    margin-bottom: 20px;
}

.flash-success {
    background: #c6f6d5;
    border: 1px solid var(--success-color);
    color: #22543d;
}

.flash-error {
    background: #fee;
    border: 1px solid var(--error-color);
    color: #c33;
}

.flash-warning {
    background: #feebc8;
    border: 1px solid var(--warning-color);
    color: #7c2d12;
}

.flash-info {
    background: #bee3f8;
    border: 1px solid var(--info-color);
    color: #2c5282;
}

/* Footer */
footer {
    margin-top: 4rem;
    padding: 2rem 0;
    border-top: 1px solid var(--border-color);
    text-align: center;
    color: var(--text-light);
    font-size: 0.9rem;
}

/* Utility Classes */
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.mb-3 { margin-bottom: 1.5rem; }
.mb-4 { margin-bottom: 2rem; }

.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.5rem; }
.mt-4 { margin-top: 2rem; }

.text-center { text-align: center; }
.text-right { text-align: right; }

/* Responsive */
@media (max-width: 768px) {
    .nav-toggle {
        display: flex;
    }

    .nav-menu {
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--white);
        flex-direction: column;
        align-items: stretch;
        padding: 1rem;
        box-shadow: var(--shadow-md);
        display: none;
        border-top: 1px solid var(--border-color);
    }

    .nav-menu.active {
        display: flex;
    }

    .nav-link {
        padding: 0.75rem 1rem;
        width: 100%;
    }

    .nav-user-info {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.5rem;
        width: 100%;
        padding: 0.75rem 1rem;
    }

    .nav-login-btn {
        width: 100%;
        margin-left: 0;
    }

    .nav-user-dropdown {
        width: 100%;
    }

    .nav-user-button {
        width: 100%;
        justify-content: space-between;
    }

    .nav-user-menu {
        position: static;
        min-width: auto;
        width: 100%;
        margin-top: 0.5rem;
        box-shadow: none;
        border: none;
        padding: 0;
    }

    .nav-user-menu.active {
        border-top: 1px solid var(--border-color);
        padding-top: 0.5rem;
    }

    .container {
        padding: 15px;
    }

    h1 {
        font-size: 1.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }
}

/* Tablet */
@media (min-width: 768px) and (max-width: 1024px) {
    .container {
        max-width: 90%;
    }
}

/* Desktop */
@media (min-width: 1024px) {
    .container {
        max-width: 1000px;
    }
}

/* Error Pages */
.error-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - 200px);
    padding: 2rem 1rem;
}

.error-content {
    text-align: center;
    max-width: 600px;
}

.error-code {
    font-size: 6rem;
    font-weight: bold;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1;
    margin-bottom: 1rem;
}

.error-title {
    font-size: 2rem;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.error-message {
    font-size: 1.125rem;
    color: var(--text-light);
    margin-bottom: 2rem;
    line-height: 1.6;
}

.error-suggestions {
    background: var(--bg-light);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    padding: 1.5rem;
    margin-bottom: 2rem;
    text-align: left;
}

.error-suggestions h2 {
    font-size: 1.125rem;
    color: var(--text-color);
    margin-bottom: 1rem;
}

.error-suggestions ul {
    list-style-type: disc;
    padding-left: 1.5rem;
}

.error-suggestions li {
    margin: 0.5rem 0;
    color: var(--text-light);
}

.error-suggestions a {
    color: var(--primary-color);
    font-weight: 500;
}

.error-actions {
    display: flex;
    gap: 1rem;
    justify-content: center;
    flex-wrap: wrap;
}

.error-actions .btn {
    padding: 0.75rem 1.5rem;
    font-size: 1rem;
}

.error-details {
    margin-top: 2rem;
    padding-top: 2rem;
    border-top: 1px solid var(--border-color);
}

.error-request-id {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-lighter);
    margin-bottom: 0.5rem;
}

.error-help-text {
    font-size: 0.875rem;
    color: var(--text-light);
    margin-bottom: 0;
}

.btn-secondary {
    background: var(--white);
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
    font-weight: 600;
}

.btn-secondary:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.3);
}

/* Error page responsive */
@media (max-width: 768px) {
    .error-code {
        font-size: 4rem;
    }

    .error-title {
        font-size: 1.5rem;
    }

    .error-message {
        font-size: 1rem;
    }

    .error-actions {
        flex-direction: column;
        align-items: stretch;
    }

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