/**
 * 印章系統後台管理樣式 v5.0
 * Cloudflare Edition
 * @author DK0124
 * @date 2025-01-31
 */

/* ===== 基礎樣式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Noto Sans TC', -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== 登入畫面 ===== */
.admin-login {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.login-container {
    background: white;
    border-radius: 20px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.1);
    width: 100%;
    max-width: 400px;
    animation: slideIn 0.5s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.login-header {
    text-align: center;
    margin-bottom: 30px;
}

.login-icon {
    font-size: 60px;
    color: #667eea;
    margin-bottom: 20px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.login-header p {
    color: #7f8c8d;
    font-size: 14px;
}

.login-form {
    margin-bottom: 20px;
}

.login-footer {
    text-align: center;
    font-size: 12px;
    color: #95a5a6;
}

.login-info {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    color: #7f8c8d;
}

.login-info .material-icons {
    font-size: 16px;
}

/* ===== 主要佈局 ===== */
.admin-container {
    display: flex;
    min-height: 100vh;
}

/* ===== 側邊欄 ===== */
.admin-sidebar {
    width: 260px;
    background: #2c3e50;
    color: white;
    display: flex;
    flex-direction: column;
    transition: all 0.3s;
    position: fixed;
    height: 100vh;
    z-index: 1000;
    overflow-y: auto;
}

.sidebar-header {
    padding: 30px 20px;
    background: rgba(0, 0, 0, 0.1);
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-logo {
    font-size: 28px;
    font-weight: bold;
    margin-bottom: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-version {
    font-size: 12px;
    opacity: 0.7;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 15px 25px;
    color: rgba(255, 255, 255, 0.8);
    text-decoration: none;
    transition: all 0.3s;
    cursor: pointer;
    border: none;
    background: none;
    width: 100%;
    text-align: left;
    font-size: 15px;
    position: relative;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
    padding-left: 30px;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left: 4px solid #667eea;
}

.nav-item .material-icons {
    margin-right: 15px;
    font-size: 20px;
}

.nav-badge {
    margin-left: auto;
    background: #e74c3c;
    color: white;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 15px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.user-info {
    flex: 1;
}

.user-name {
    font-weight: 500;
    font-size: 14px;
}

.user-role {
    font-size: 12px;
    opacity: 0.7;
}

/* ===== 主內容區 ===== */
.admin-main {
    flex: 1;
    margin-left: 260px;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.admin-header {
    background: white;
    padding: 20px 30px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-title {
    display: flex;
    align-items: center;
    gap: 15px;
}

.header-title h2 {
    font-size: 24px;
    font-weight: 600;
    color: #2c3e50;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.admin-content {
    flex: 1;
    padding: 30px;
    overflow-y: auto;
}

/* ===== 卡片樣式 ===== */
.admin-card {
    background: white;
    border-radius: 12px;
    box-shadow: 0 2px 20px rgba(0, 0, 0, 0.05);
    padding: 25px;
    margin-bottom: 25px;
    transition: all 0.3s;
}

.admin-card:hover {
    box-shadow: 0 5px 30px rgba(0, 0, 0, 0.08);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e9ecef;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    color: #2c3e50;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-title .material-icons {
    color: #667eea;
}

/* ===== 統計卡片 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 15px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
    cursor: pointer;
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 25px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 60px;
    height: 60px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
}

.stat-icon.primary { background: rgba(102, 126, 234, 0.1); color: #667eea; }
.stat-icon.success { background: rgba(46, 213, 115, 0.1); color: #2ed573; }
.stat-icon.warning { background: rgba(255, 183, 77, 0.1); color: #ffb74d; }
.stat-icon.danger { background: rgba(231, 76, 60, 0.1); color: #e74c3c; }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: #2c3e50;
    margin-bottom: 5px;
}

.stat-label {
    font-size: 14px;
    color: #7f8c8d;
}

.stat-change {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    margin-top: 10px;
    padding: 4px 10px;
    border-radius: 20px;
}

.stat-change.positive {
    background: rgba(46, 213, 115, 0.1);
    color: #2ed573;
}

.stat-change.negative {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* ===== 表格樣式 ===== */
.admin-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

.admin-table thead {
    background: #f8f9fa;
}

.admin-table th {
    text-align: left;
    padding: 15px;
    font-weight: 600;
    color: #2c3e50;
    font-size: 14px;
    border-bottom: 2px solid #e9ecef;
}

.admin-table td {
    padding: 15px;
    border-bottom: 1px solid #f1f3f4;
    vertical-align: middle;
}

.admin-table tbody tr {
    transition: all 0.2s;
}

.admin-table tbody tr:hover {
    background: #f8f9fa;
}

/* ===== 按鈕樣式 ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    text-decoration: none;
    font-family: inherit;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(102, 126, 234, 0.3);
}

.btn-secondary {
    background: #e9ecef;
    color: #495057;
}

.btn-secondary:hover:not(:disabled) {
    background: #dee2e6;
}

.btn-success {
    background: #2ed573;
    color: white;
}

.btn-danger {
    background: #e74c3c;
    color: white;
}

.btn-warning {
    background: #ffb74d;
    color: white;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-lg {
    padding: 12px 30px;
    font-size: 16px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    padding: 8px;
    border-radius: 50%;
}

/* ===== 表單樣式 ===== */
.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    margin-bottom: 8px;
    font-size: 14px;
    color: #495057;
}

.form-label .material-icons {
    font-size: 18px;
    color: #667eea;
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    font-size: 15px;
    transition: all 0.3s;
    font-family: inherit;
}

.form-control:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-control:disabled {
    background: #f8f9fa;
    cursor: not-allowed;
}

.form-select {
    cursor: pointer;
    background: white 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='%23333' d='M10.293 3.293L6 7.586 1.707 3.293A1 1 0 00.293 4.707l5 5a1 1 0 001.414 0l5-5a1 1 0 10-1.414-1.414z'/%3E%3C/svg%3E") no-repeat right 16px center;
    padding-right: 40px;
}

textarea.form-control {
    min-height: 100px;
    resize: vertical;
}

.help-text {
    font-size: 13px;
    color: #6c757d;
    margin-top: 5px;
}

/* ===== Switch 開關 ===== */
.form-switch {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
}

.switch {
    position: relative;
    width: 48px;
    height: 24px;
    background: #e9ecef;
    border-radius: 12px;
    transition: all 0.3s;
}

.switch::after {
    content: '';
    position: absolute;
    top: 2px;
    left: 2px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 10px;
    transition: all 0.3s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.form-switch input[type="checkbox"] {
    display: none;
}

.form-switch input[type="checkbox"]:checked + .switch {
    background: #667eea;
}

.form-switch input[type="checkbox"]:checked + .switch::after {
    transform: translateX(24px);
}

/* ===== 檔案上傳 ===== */
.upload-area {
    border: 2px dashed #e9ecef;
    border-radius: 12px;
    padding: 40px;
    text-align: center;
    transition: all 0.3s;
    cursor: pointer;
    background: #f8f9fa;
}

.upload-area:hover {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.05);
}

.upload-area.drag-over {
    border-color: #667eea;
    background: rgba(102, 126, 234, 0.1);
}

.upload-icon {
    font-size: 48px;
    color: #667eea;
    margin-bottom: 16px;
}

.upload-text {
    font-size: 16px;
    color: #495057;
    margin-bottom: 8px;
}

.upload-hint {
    font-size: 14px;
    color: #6c757d;
}

.file-list {
    margin-top: 20px;
}

.file-item {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #f8f9fa;
    border-radius: 8px;
    margin-bottom: 10px;
    transition: all 0.3s;
}

.file-item:hover {
    background: #e9ecef;
}

.file-icon {
    width: 40px;
    height: 40px;
    background: rgba(102, 126, 234, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 12px;
    color: #667eea;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    color: #2c3e50;
    margin-bottom: 2px;
}

.file-size {
    font-size: 13px;
    color: #6c757d;
}

.file-actions {
    display: flex;
    gap: 8px;
}

/* ===== 分頁 ===== */
.pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 30px;
}

.page-item {
    padding: 8px 12px;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    color: #495057;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 14px;
}

.page-item:hover {
    border-color: #667eea;
    color: #667eea;
}

.page-item.active {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

.page-item.disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== 空狀態 ===== */
.empty-state {
    text-align: center;
    padding: 60px 20px;
}

.empty-icon {
    font-size: 72px;
    color: #dee2e6;
    margin-bottom: 20px;
}

.empty-title {
    font-size: 20px;
    font-weight: 600;
    color: #495057;
    margin-bottom: 10px;
}

.empty-text {
    color: #6c757d;
    margin-bottom: 20px;
}

/* ===== 載入狀態 ===== */
.loading-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid #f1f3f4;
    border-top-color: #667eea;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== 通知樣式 ===== */
.notification-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
    pointer-events: none;
}

.notification {
    background: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.1);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 300px;
    pointer-events: all;
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.notification.success {
    border-left: 4px solid #2ed573;
}

.notification.danger {
    border-left: 4px solid #e74c3c;
}

.notification.warning {
    border-left: 4px solid #ffb74d;
}

.notification.info {
    border-left: 4px solid #667eea;
}

.notification-icon {
    font-size: 24px;
}

.notification.success .notification-icon { color: #2ed573; }
.notification.danger .notification-icon { color: #e74c3c; }
.notification.warning .notification-icon { color: #ffb74d; }
.notification.info .notification-icon { color: #667eea; }

.notification-content {
    flex: 1;
}

.notification-title {
    font-weight: 600;
    margin-bottom: 2px;
}

.notification-message {
    font-size: 14px;
    color: #6c757d;
}

.notification-close {
    cursor: pointer;
    color: #adb5bd;
    transition: color 0.3s;
}

.notification-close:hover {
    color: #495057;
}

/* ===== Modal 樣式 ===== */
.admin-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 9998;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.admin-modal.show {
    display: flex;
}

.admin-modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.admin-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 25px;
    border-bottom: 1px solid #e9ecef;
}

.admin-modal-header h3 {
    font-size: 20px;
    font-weight: 600;
    color: #2c3e50;
}

.admin-modal-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

/* ===== Badge 樣式 ===== */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 500;
    border-radius: 20px;
}

.badge-primary {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
}

.badge-success {
    background: rgba(46, 213, 115, 0.1);
    color: #2ed573;
}

.badge-warning {
    background: rgba(255, 183, 77, 0.1);
    color: #ff9f43;
}

.badge-danger {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* ===== 響應式設計 ===== */
@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%);
    }
    
    .admin-sidebar.show {
        transform: translateX(0);
    }
    
    .admin-main {
        margin-left: 0;
    }
    
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    }
}

@media (max-width: 768px) {
    .admin-header {
        padding: 15px 20px;
    }
    
    .admin-content {
        padding: 20px;
    }
    
    .admin-card {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .admin-table {
        font-size: 14px;
    }
    
    .admin-table th,
    .admin-table td {
        padding: 10px;
    }
    
    .hide-mobile {
        display: none;
    }
    
    .notification {
        min-width: auto;
        right: 10px;
        left: 10px;
    }
}

/* ===== 進度條 ===== */
.progress {
    height: 8px;
    background: #e9ecef;
    border-radius: 4px;
    overflow: hidden;
    margin: 10px 0;
}

.progress-bar {
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 4px;
    transition: width 0.3s ease;
}

/* ===== 工具提示 ===== */
.tooltip {
    position: relative;
}

.tooltip-text {
    visibility: hidden;
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    background: #2c3e50;
    color: white;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: nowrap;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #2c3e50;
}

.tooltip:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* ===== 標籤頁 ===== */
.tabs {
    display: flex;
    border-bottom: 2px solid #e9ecef;
    margin-bottom: 25px;
}

.tab {
    padding: 12px 24px;
    color: #6c757d;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    transition: all 0.3s;
    font-weight: 500;
    margin-bottom: -2px;
}

.tab:hover {
    color: #495057;
}

.tab.active {
    color: #667eea;
    border-bottom-color: #667eea;
}

/* ===== 特殊樣式 ===== */
.font-preview-cell {
    font-size: 20px;
    font-weight: bold;
    text-align: center;
}

.color-preview {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 4px;
    vertical-align: middle;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

.shape-preview {
    width: 30px;
    height: 30px;
    border: 2px solid currentColor;
    display: inline-block;
    vertical-align: middle;
}

.shape-preview.circle {
    border-radius: 50%;
}

.shape-preview.ellipse {
    border-radius: 50%;
    width: 40px;
    height: 25px;
}

.shape-preview.rectangle {
    width: 40px;
    height: 25px;
}

/* ===== 動畫效果 ===== */
.fade-in {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.slide-up {
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== 列印樣式 ===== */
@media print {
    .admin-sidebar,
    .admin-header,
    .header-actions,
    .btn,
    .notification-container {
        display: none !important;
    }
    
    .admin-main {
        margin-left: 0;
    }
    
    .admin-content {
        padding: 0;
    }
    
    .admin-card {
        box-shadow: none;
        border: 1px solid #dee2e6;
        break-inside: avoid;
    }
}