/* Apple-style Design System */
:root {
    --color-bg: #000000;
    --color-bg-secondary: #1c1c1e;
    --color-bg-tertiary: #2c2c2e;
    --color-surface: #1c1c1e;
    --color-surface-elevated: #2c2c2e;
    --color-text-primary: #f5f5f7;
    --color-text-secondary: #86868b;
    --color-text-tertiary: #6e6e73;
    --color-accent: #0a84ff;
    --color-accent-hover: #409cff;
    --color-success: #30d158;
    --color-danger: #ff453a;
    --color-border: #38383a;
    --color-border-light: #48484a;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 24px;
    --font-family: -apple-system, BlinkMacSystemFont, "SF Pro Display", "Helvetica Neue", Arial, sans-serif;
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.4);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.5);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--color-bg);
    color: var(--color-text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

button, input, select, textarea, a {
    outline: none;
}

/* Background */
.bg-gradient {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-bg);
    z-index: -1;
}

.bg-gradient::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 60vh;
    background: radial-gradient(ellipse at 50% 0%, rgba(10, 132, 255, 0.15) 0%, transparent 60%);
    pointer-events: none;
}

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

/* Typography */
h1, h2, h3, h4 {
    font-weight: 600;
    letter-spacing: -0.02em;
}

/* User Home Page */
.home-wrapper {
    padding-top: 15vh;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.home-header {
    text-align: center;
    margin-bottom: 48px;
}

.home-header h1 {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--color-text-primary);
    margin-bottom: 12px;
}

.home-header p {
    font-size: 1.25rem;
    color: var(--color-text-secondary);
    letter-spacing: -0.01em;
}

/* Message Form */
.message-form {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 32px;
    border: 1px solid var(--color-border);
}

.message-form textarea {
    width: 100%;
    min-height: 140px;
    padding: 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1.0625rem;
    font-family: inherit;
    resize: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.message-form textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.message-form textarea::placeholder {
    color: var(--color-text-tertiary);
}

.message-form .btn-primary {
    width: 100%;
    margin-top: 16px;
    padding: 16px 32px;
    font-size: 1.0625rem;
    font-weight: 600;
    border-radius: var(--radius-md);
    background: var(--color-accent);
    color: white;
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    letter-spacing: 0.01em;
}

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

.message-form .btn-primary:active {
    transform: scale(0.98);
}

/* Success Message */
.success-message {
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 48px 32px;
    text-align: center;
    border: 1px solid var(--color-border);
    margin-top: 24px;
}

.success-message .check-icon {
    width: 64px;
    height: 64px;
    margin: 0 auto 24px;
    background: var(--color-success);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.success-message .check-icon svg {
    width: 32px;
    height: 32px;
    fill: white;
}

.success-message h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--color-text-primary);
}

.success-message p {
    color: var(--color-text-secondary);
    font-size: 1rem;
}

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

/* Login Page */
.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.login-container {
    width: 100%;
    max-width: 400px;
    background: var(--color-surface);
    border-radius: var(--radius-xl);
    padding: 48px 40px;
    border: 1px solid var(--color-border);
}

.login-container h2 {
    text-align: center;
    font-size: 1.75rem;
    margin-bottom: 32px;
    color: var(--color-text-primary);
}

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

.form-group input {
    width: 100%;
    padding: 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.form-group input:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

.form-group input::placeholder {
    color: var(--color-text-tertiary);
}

.btn-primary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    background: var(--color-accent);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
    text-decoration: none;
}

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

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

.btn-full {
    width: 100%;
}

.btn-secondary {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 14px 28px;
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    font-size: 1rem;
    font-weight: 500;
    font-family: inherit;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
    text-decoration: none;
    height: 52px;
    box-sizing: border-box;
}

.btn-secondary:hover {
    background: var(--color-surface-elevated);
    border-color: var(--color-border-light);
}

.btn-danger {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    background: var(--color-danger);
    color: white;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    text-decoration: none;
}

.btn-danger:hover {
    opacity: 0.9;
}

.btn-link {
    color: var(--color-accent);
    text-decoration: none;
    font-size: 0.9375rem;
    transition: opacity 0.2s;
}

.btn-link:hover {
    opacity: 0.8;
}

/* Alert */
.alert-error {
    background: rgba(255, 69, 58, 0.12);
    border: 1px solid rgba(255, 69, 58, 0.3);
    color: #ff6b6b;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9375rem;
}

.alert-success {
    background: rgba(48, 209, 88, 0.12);
    border: 1px solid rgba(48, 209, 88, 0.3);
    color: #4ade80;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-size: 0.9375rem;
}

/* Admin Navigation */
.admin-nav {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(28, 28, 30, 0.8);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--color-border);
    padding: 0 20px;
}

.admin-nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 56px;
}

.nav-brand a {
    color: var(--color-text-primary);
    text-decoration: none;
    font-weight: 600;
    font-size: 1.0625rem;
    letter-spacing: -0.01em;
}

.nav-links {
    display: flex;
    gap: 8px;
}

.nav-links a {
    color: var(--color-text-secondary);
    text-decoration: none;
    font-size: 0.9375rem;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    transition: background 0.2s, color 0.2s;
}

.nav-links a:hover {
    background: var(--color-bg-tertiary);
    color: var(--color-text-primary);
}

.nav-links a.active {
    color: var(--color-text-primary);
}

.nav-links .logout-link {
    color: var(--color-danger);
}

.nav-links .logout-link:hover {
    background: rgba(255, 69, 58, 0.12);
    color: var(--color-danger);
}

/* Admin Content */
.admin-wrapper {
    padding: 40px 20px;
    max-width: 1200px;
    margin: 0 auto;
}

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

.page-header h2 {
    font-size: 2rem;
    letter-spacing: -0.03em;
}

.count-badge {
    background: var(--color-bg-tertiary);
    color: var(--color-text-secondary);
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.875rem;
    font-weight: 500;
}

/* Dashboard Stats */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 40px;
}

.stat-card {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--color-border);
    text-align: center;
}

.stat-value {
    font-size: 3rem;
    font-weight: 700;
    letter-spacing: -0.04em;
    color: var(--color-accent);
    line-height: 1;
    margin-bottom: 8px;
}

.stat-label {
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
}

/* Quick Actions */
.quick-actions {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--color-border);
}

.quick-actions h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
    color: var(--color-text-primary);
}

.action-btns {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* Messages Table */
.messages-table {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 16px 20px;
    text-align: left;
    border-bottom: 1px solid var(--color-border);
}

th {
    color: var(--color-text-secondary);
    font-weight: 600;
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    background: var(--color-bg-tertiary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

.msg-id {
    font-family: ui-monospace, monospace;
    font-size: 0.8125rem;
    color: var(--color-text-tertiary);
}

.msg-preview {
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--color-text-secondary);
}

.ip-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.ip-info span {
    font-family: ui-monospace, monospace;
    font-size: 0.8125rem;
}

.ip-info small {
    color: var(--color-text-tertiary);
    font-size: 0.75rem;
}

.msg-time {
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
    white-space: nowrap;
}

/* Message Detail */
.message-detail {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--color-border);
    margin-bottom: 24px;
}

.detail-meta {
    display: flex;
    justify-content: space-between;
    margin-bottom: 24px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--color-border);
}

.detail-id {
    font-family: ui-monospace, monospace;
    font-size: 0.8125rem;
    color: var(--color-text-tertiary);
}

.detail-time {
    color: var(--color-text-tertiary);
    font-size: 0.875rem;
}

.detail-info {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.info-item {
    display: flex;
    gap: 8px;
    font-size: 0.9375rem;
}

.info-item label {
    color: var(--color-text-tertiary);
    flex-shrink: 0;
}

.info-item span {
    color: var(--color-text-primary);
}

.detail-content {
    margin-top: 20px;
}

.detail-content label {
    display: block;
    color: var(--color-text-tertiary);
    font-size: 0.8125rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 12px;
}

.content-box {
    background: var(--color-bg-tertiary);
    padding: 20px;
    border-radius: var(--radius-md);
    font-size: 1rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

/* Replies */
.replies-section {
    margin-bottom: 24px;
}

.replies-section h3 {
    font-size: 1.125rem;
    margin-bottom: 16px;
}

.reply-card {
    background: var(--color-surface);
    border-radius: var(--radius-md);
    padding: 20px;
    border: 1px solid var(--color-border);
    margin-bottom: 12px;
}

.reply-meta {
    font-size: 0.8125rem;
    color: var(--color-accent);
    margin-bottom: 8px;
}

.reply-content {
    color: var(--color-text-primary);
    line-height: 1.6;
    white-space: pre-wrap;
}

/* Reply Form */
.reply-form {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--color-border);
}

.reply-form h3 {
    font-size: 1.125rem;
    margin-bottom: 20px;
}

.reply-form textarea {
    width: 100%;
    min-height: 100px;
    padding: 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    font-family: inherit;
    resize: vertical;
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.reply-form textarea:focus {
    outline: none;
    border-color: var(--color-accent);
    box-shadow: 0 0 0 3px rgba(10, 132, 255, 0.2);
}

/* Settings */
.settings-section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 32px;
    border: 1px solid var(--color-border);
}

.settings-section h3 {
    font-size: 1.25rem;
    margin-bottom: 24px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-group-sm {
    max-width: 120px;
}

.form-group select {
    width: 100%;
    padding: 14px 16px;
    background: var(--color-bg-tertiary);
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-primary);
    font-size: 1rem;
    font-family: inherit;
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2386868b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 16px center;
}

.form-group select:focus {
    outline: none;
    border-color: var(--color-accent);
}

/* Data Management */
.data-section {
    background: var(--color-surface);
    border-radius: var(--radius-lg);
    padding: 28px;
    border: 1px solid var(--color-border);
    margin-bottom: 20px;
}

.data-section h3 {
    font-size: 1.125rem;
    margin-bottom: 8px;
}

.data-section p {
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
    margin-bottom: 16px;
}

.danger-zone {
    border-color: rgba(255, 69, 58, 0.3);
}

.danger-zone h3 {
    color: var(--color-danger);
}

.file-input-wrapper {
    position: relative;
    margin-bottom: 16px;
    height: 52px;
}

.file-input-wrapper input[type="file"] {
    position: absolute;
    width: 100%;
    height: 100%;
    top: 0;
    left: 0;
    opacity: 0;
    cursor: pointer;
}

.file-input-display {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 20px;
    height: 100%;
    background: var(--color-bg-tertiary);
    border: 1px dashed var(--color-border);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    box-sizing: border-box;
}

.file-input-wrapper:hover .file-input-display,
.file-input-wrapper input[type="file"]:focus + .file-input-display {
    border-color: var(--color-accent);
    color: var(--color-accent);
    background: rgba(10, 132, 255, 0.05);
}

.file-input-display svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Toast Notification */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 14px 20px;
    border-radius: var(--radius-md);
    font-size: 0.9375rem;
    font-weight: 500;
    z-index: 9999;
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-success {
    background: rgba(48, 209, 88, 0.15);
    border: 1px solid rgba(48, 209, 88, 0.3);
    color: #30d158;
}

.toast-error {
    background: rgba(255, 69, 58, 0.15);
    border: 1px solid rgba(255, 69, 58, 0.3);
    color: #ff453a;
}

@media (max-width: 768px) {
    .toast {
        top: auto;
        bottom: 20px;
        left: 20px;
        right: 20px;
        transform: translateY(10px);
    }
    .toast.show {
        transform: translateY(0);
    }
}

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

    .home-header p {
        font-size: 1.0625rem;
    }

    .message-form {
        padding: 24px;
        border-radius: var(--radius-lg);
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .stat-value {
        font-size: 2.5rem;
    }

    .form-row {
        grid-template-columns: 1fr;
    }

    .detail-info {
        grid-template-columns: 1fr;
    }

    .nav-links {
        gap: 4px;
    }

    .nav-links a {
        padding: 8px 12px;
        font-size: 0.875rem;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    table {
        font-size: 0.875rem;
    }

    th, td {
        padding: 12px;
    }

    .msg-preview {
        display: none;
    }

    .admin-nav-inner {
        flex-direction: column;
        height: auto;
        padding: 12px 0;
        gap: 12px;
    }

    .nav-links {
        flex-wrap: wrap;
        justify-content: center;
    }

    .action-btns {
        flex-direction: column;
    }

    .action-btns a {
        width: 100%;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 16px;
    }

    .home-wrapper {
        padding-top: 10vh;
    }

    .home-header h1 {
        font-size: 1.875rem;
    }

    .login-container {
        padding: 32px 24px;
    }

    .page-header h2 {
        font-size: 1.5rem;
    }

    .message-detail {
        padding: 20px;
    }

    .settings-section {
        padding: 24px;
    }
}
