/* Nakoshi P1 - Homunculus Theme */
/* Psychological horror inspired: stark monochrome, high contrast, clinical */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

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

/* Dark Theme (Default - Homunculus aesthetic) */
:root[data-theme="dark"], :root {
    --background: 0 0% 7%;
    --foreground: 0 0% 98%;
    --card: 0 0% 10%;
    --card-foreground: 0 0% 98%;
    --primary: 0 0% 98%;
    --primary-foreground: 0 0% 7%;
    --secondary: 0 0% 20%;
    --secondary-foreground: 0 0% 98%;
    --muted: 0 0% 15%;
    --muted-foreground: 0 0% 60%;
    --accent: 0 0% 18%;
    --accent-foreground: 0 0% 98%;
    --border: 0 0% 18%;
    --input: 0 0% 18%;
    --ring: 0 0% 40%;
    --success: 142 71% 45%;
    --warning: 38 92% 50%;
    --destructive: 0 72% 51%;
    --radius: 0.5rem;
    --sidebar-width: 280px;
}

/* Light Theme */
:root[data-theme="light"] {
    --background: 0 0% 100%;
    --foreground: 0 0% 7%;
    --card: 0 0% 98%;
    --card-foreground: 0 0% 7%;
    --primary: 0 0% 7%;
    --primary-foreground: 0 0% 98%;
    --secondary: 0 0% 93%;
    --secondary-foreground: 0 0% 7%;
    --muted: 0 0% 93%;
    --muted-foreground: 0 0% 40%;
    --accent: 0 0% 95%;
    --accent-foreground: 0 0% 7%;
    --border: 0 0% 88%;
    --input: 0 0% 88%;
    --ring: 0 0% 60%;
    --success: 142 71% 45%;
    --warning: 38 92% 50%;
    --destructive: 0 72% 51%;
    --radius: 0.5rem;
    --sidebar-width: 280px;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    transition: background-color 0.3s, color 0.3s;
}

.container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: hsl(var(--card));
    border-right: 1px solid hsl(var(--border));
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 40;
}

.sidebar-header {
    padding: 2rem 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.logo {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    letter-spacing: -0.02em;
}

.sidebar-nav {
    flex: 1;
    padding: 1.5rem 1rem;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    margin-bottom: 0.25rem;
    border-radius: var(--radius);
    color: hsl(var(--muted-foreground));
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.nav-item:hover {
    background: hsl(var(--accent));
    color: hsl(var(--accent-foreground));
}

.nav-item.active {
    background: hsl(var(--accent));
    color: hsl(var(--primary));
    font-weight: 600;
}

.nav-icon {
    width: 20px;
    height: 20px;
    opacity: 0.9;
}

.sidebar-footer {
    padding: 1.5rem;
    border-top: 1px solid hsl(var(--border));
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: var(--radius);
    background: hsl(var(--accent));
    transition: all 0.2s;
}

.user-profile:hover {
    background: hsl(var(--muted));
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: hsl(var(--primary));
    display: flex;
    align-items: center;
    justify-content: center;
    color: hsl(var(--primary-foreground));
    font-weight: 600;
    font-size: 1.125rem;
}

.user-info {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-weight: 600;
    font-size: 0.9375rem;
    color: hsl(var(--foreground));
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.user-role {
    font-size: 0.8125rem;
    color: hsl(var(--muted-foreground));
}

/* Main Content */
.main {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
}

.header {
    background: hsl(var(--card) / 0.8);
    border-bottom: 1px solid hsl(var(--border));
    padding: 1.25rem 2rem;
    position: sticky;
    top: 0;
    z-index: 30;
    backdrop-filter: blur(8px);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: hsl(var(--foreground));
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Buttons */
.btn {
    padding: 0.625rem 1.25rem;
    font-size: 0.9375rem;
    font-weight: 500;
    border-radius: var(--radius);
    border: none;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    white-space: nowrap;
}

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

.btn-primary:hover {
    background: hsl(var(--primary) / 0.9);
    transform: translateY(-1px);
}

.btn-secondary {
    background: hsl(var(--secondary));
    color: hsl(var(--secondary-foreground));
}

.btn-secondary:hover {
    background: hsl(var(--secondary) / 0.8);
}

.btn-ghost {
    background: transparent;
    color: hsl(var(--foreground));
    border: 1px solid hsl(var(--border));
}

.btn-ghost:hover {
    background: hsl(var(--accent));
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
}

/* Content */
.content {
    padding: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    padding: 1.5rem;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.stat-card:hover {
    transform: translateY(-2px);
    border-color: hsl(var(--ring));
}

.stat-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--muted-foreground));
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value {
    font-size: 2rem;
    font-weight: 700;
    color: hsl(var(--foreground));
    line-height: 1.2;
}

.stat-change {
    font-size: 0.8125rem;
    margin-top: 0.5rem;
    font-weight: 500;
}

.stat-change.positive {
    color: hsl(var(--success));
}

.stat-change.negative {
    color: hsl(var(--destructive));
}

.card {
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    border-radius: var(--radius);
    margin-bottom: 1.5rem;
    overflow: hidden;
}

.card-header {
    padding: 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.card-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: hsl(var(--foreground));
}

.card-content {
    padding: 1.5rem;
}

.card-actions {
    display: flex;
    gap: 0.75rem;
}

/* Table */
table {
    width: 100%;
    border-collapse: collapse;
}

thead {
    background: hsl(var(--muted));
}

th {
    padding: 0.75rem 1rem;
    text-align: left;
    font-size: 0.875rem;
    font-weight: 600;
    color: hsl(var(--foreground));
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td {
    padding: 1rem;
    border-bottom: 1px solid hsl(var(--border));
    font-size: 0.9375rem;
    color: hsl(var(--foreground));
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: hsl(var(--accent));
}

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

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: calc(var(--radius) - 2px);
    white-space: nowrap;
}

.badge-success {
    background: hsl(var(--success) / 0.15);
    color: hsl(var(--success));
}

.badge-warning {
    background: hsl(var(--warning) / 0.15);
    color: hsl(var(--warning));
}

.badge-destructive {
    background: hsl(var(--destructive) / 0.15);
    color: hsl(var(--destructive));
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: hsl(var(--card));
    border-radius: var(--radius);
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    border: 1px solid hsl(var(--border));
}

.modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid hsl(var(--border));
}

.modal-title {
    font-size: 1.125rem;
    font-weight: 600;
}

.modal-body {
    padding: 1.5rem;
}

.modal-footer {
    padding: 1.5rem;
    border-top: 1px solid hsl(var(--border));
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
}

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

.label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: hsl(var(--foreground));
}

.input {
    width: 100%;
    padding: 0.625rem 0.75rem;
    font-size: 0.9375rem;
    border: 1px solid hsl(var(--input));
    border-radius: var(--radius);
    background: hsl(var(--background));
    color: hsl(var(--foreground));
    transition: all 0.2s;
}

.input:focus {
    outline: none;
    border-color: hsl(var(--ring));
    box-shadow: 0 0 0 3px hsl(var(--ring) / 0.1);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    color: hsl(var(--muted-foreground));
}

.empty-icon {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* Loading */
.loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid hsl(var(--muted));
    border-top-color: hsl(var(--primary));
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Theme Toggle */
.theme-toggle {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: hsl(var(--card));
    border: 1px solid hsl(var(--border));
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    z-index: 50;
}

.theme-toggle:hover {
    transform: scale(1.1);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .main {
        margin-left: 0;
    }

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

    .header-content {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
}
