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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    line-height: 1.5;
    background: #f7f8fa;
    color: #191f28;
    font-size: 15px;
}

/* Layout */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    background: #fff;
    border-bottom: 1px solid #f1f3f5;
}

.header h1 {
    font-size: 18px;
    font-weight: 600;
}

.header nav {
    display: flex;
    gap: 12px;
    align-items: center;
}

.header nav span {
    color: #6b7684;
    font-size: 14px;
}

.main {
    max-width: 800px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 8px 16px;
    background: #f2f4f6;
    color: #191f28;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: background 0.15s;
}

.btn:hover {
    background: #e5e8eb;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-primary {
    background: #114d9c;
    color: #fff;
}

.btn-primary:hover {
    background: #0d3a75;
}

.btn-danger {
    background: #fff;
    color: #f04452;
    border: 1px solid #fdebed;
}

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

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

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

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #4e5968;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e5e8eb;
    border-radius: 10px;
    font-size: 15px;
    background: #fff;
    transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #114d9c;
}

.form-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 180px;
}

.form-inline {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.form-inline .form-group {
    margin-bottom: 0;
}

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.checkbox-group label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-weight: normal;
    cursor: pointer;
}

/* Radio buttons styled */
.radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.radio-card {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border: 1px solid #e5e8eb;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s;
}

.radio-card:hover {
    border-color: #114d9c;
}

.radio-card input {
    display: none;
}

.radio-card input:checked + .radio-label {
    color: #114d9c;
}

.radio-card:has(input:checked) {
    border-color: #114d9c;
    background: #f2f7ff;
}

/* Alerts */
.alert {
    padding: 14px 16px;
    border-radius: 10px;
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: #e8f5e9;
    color: #1b5e20;
}

.alert-error {
    background: #fdebed;
    color: #c62828;
}

/* Login Page */
.login-page {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: #fff;
}

.login-container {
    width: 100%;
    max-width: 360px;
    padding: 40px 24px;
}

.login-brand {
    text-align: center;
    margin-bottom: 32px;
}

.login-brand h1 {
    font-size: 26px;
    font-weight: 700;
    color: #114d9c;
    margin-bottom: 8px;
}

.login-subtitle {
    font-size: 15px;
    color: #6b7684;
    font-weight: 400;
}

.login-form .btn {
    margin-top: 8px;
}

/* File List */
.category {
    background: #fff;
    border-radius: 16px;
    padding: 20px;
    margin-bottom: 16px;
}

.category h2 {
    font-size: 13px;
    color: #8b95a1;
    font-weight: 500;
    margin-bottom: 12px;
    padding-left: 4px;
}

.file-list {
    list-style: none;
}

.file-item {
    border-bottom: 1px solid #f1f3f5;
}

.file-item:last-child {
    border-bottom: none;
}

.file-link {
    display: flex;
    align-items: center;
    padding: 14px 8px;
    text-decoration: none;
    color: #191f28;
    border-radius: 8px;
    transition: background 0.15s;
}

.file-link:hover {
    background: #f7f8fa;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: #f2f4f6;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 14px;
    flex-shrink: 0;
}

.file-icon svg {
    width: 20px;
    height: 20px;
    color: #6b7684;
}

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

.file-name {
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-meta {
    font-size: 13px;
    color: #8b95a1;
    margin-top: 2px;
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: #8b95a1;
}

/* Admin */
.admin-main {
    max-width: 960px;
}

.stats {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.stat-card {
    background: #fff;
    padding: 20px 24px;
    border-radius: 16px;
    flex: 1;
}

.stat-number {
    display: block;
    font-size: 28px;
    font-weight: 600;
    color: #191f28;
}

.stat-label {
    color: #8b95a1;
    font-size: 14px;
    margin-top: 4px;
}

.admin-menu {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: #fff;
    border-radius: 12px;
    text-decoration: none;
    color: #191f28;
    flex: 1;
    transition: background 0.15s;
}

.admin-menu-item:hover {
    background: #f7f8fa;
}

.admin-menu-item .icon {
    width: 44px;
    height: 44px;
    background: #f2f4f6;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-menu-item .icon svg {
    width: 22px;
    height: 22px;
    color: #6b7684;
}

.admin-menu-item .label {
    font-weight: 500;
}

/* Section */
.section {
    background: #fff;
    padding: 20px;
    border-radius: 16px;
    margin-bottom: 16px;
}

.section h2 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 16px;
}

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

.table th,
.table td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #f1f3f5;
    font-size: 14px;
}

.table th {
    color: #8b95a1;
    font-weight: 500;
}

.table tbody tr:hover {
    background: #f7f8fa;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal-content {
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    width: 100%;
    max-width: 440px;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content h3 {
    font-size: 18px;
    margin-bottom: 20px;
}

.form-actions {
    display: flex;
    gap: 8px;
    margin-top: 24px;
}

/* Utilities */
.text-center {
    text-align: center;
}

.text-muted {
    color: #8b95a1;
}

.help-text {
    font-size: 13px;
    color: #8b95a1;
    margin-top: 6px;
}

.folder-structure {
    background: #f7f8fa;
    color: #4e5968;
    padding: 16px;
    border-radius: 10px;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 13px;
    overflow-x: auto;
}

code {
    background: #f2f4f6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
}

/* Error Page */
.error-page {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
}

.error-page h1 {
    font-size: 64px;
    color: #e5e8eb;
    font-weight: 700;
}

.error-page p {
    margin: 16px 0 24px;
    color: #8b95a1;
}

/* Viewer Toolbar */
.toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    background: #fff;
    border-bottom: 1px solid #f1f3f5;
    position: sticky;
    top: 0;
    z-index: 100;
}

.toolbar .title {
    flex: 1;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.color-picker {
    display: flex;
    gap: 6px;
}

.color-btn {
    width: 28px;
    height: 28px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.15s;
}

.color-btn:hover {
    transform: scale(1.1);
}

.color-btn.active {
    border-color: #191f28;
}

/* Viewer */
.viewer-container {
    background: #e5e8eb;
    min-height: calc(100vh - 57px);
    padding: 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.page-container {
    position: relative;
    background: #fff;
    margin-bottom: 16px;
    border-radius: 4px;
}

.watermark {
    position: absolute;
    pointer-events: none;
    user-select: none;
    z-index: 10;
    color: var(--watermark-color, rgba(200, 0, 0, 0.2));
    font-size: var(--watermark-size, 32px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.watermark-logo {
    max-width: 120px;
    max-height: 120px;
    object-fit: contain;
}

/* Watermark positions */
.watermark.diagonal {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-45deg);
    white-space: nowrap;
}

.watermark.center {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.watermark.circle {
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 180px;
    height: 180px;
}

.watermark.circle svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}

.watermark.circle .watermark-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 60px;
    max-height: 60px;
}

.watermark.top {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.watermark.bottom {
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
}

.watermark.top-left {
    top: 20px;
    left: 20px;
    align-items: flex-start;
}

.watermark.top-right {
    top: 20px;
    right: 20px;
    align-items: flex-end;
}

.watermark.bottom-left {
    bottom: 20px;
    left: 20px;
    align-items: flex-start;
}

.watermark.bottom-right {
    bottom: 20px;
    right: 20px;
    align-items: flex-end;
}

.watermark.tile {
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 60px;
    padding: 40px;
    font-size: 18px;
}

.watermark.tile span {
    transform: rotate(-45deg);
    white-space: nowrap;
}

.watermark.tile .watermark-logo {
    display: none;
}

/* Responsive */
@media (max-width: 768px) {
    .header {
        padding: 12px 16px;
    }
    
    .header h1 {
        font-size: 16px;
    }
    
    .stats {
        flex-direction: column;
    }
    
    .admin-menu {
        flex-direction: column;
    }
    
    .form-row {
        flex-direction: column;
    }
    
    .table {
        font-size: 13px;
    }
    
    .table th,
    .table td {
        padding: 10px 8px;
    }
}

/* Admin Footer */
.admin-footer {
    text-align: center;
    padding: 32px 16px;
    margin-top: 48px;
    color: #8b95a1;
    font-size: 13px;
}

.admin-footer a {
    color: #6b7684;
    text-decoration: none;
}

.admin-footer a:hover {
    color: #114d9c;
}

/* Print */
@media print {
    .toolbar { display: none; }
    .draw-canvas { display: none; }
    .viewer-container { 
        background: white; 
        padding: 0;
    }
    .page-container {
        margin: 0;
        page-break-after: always;
    }
}
