/* =====================================================
   PTN Electronics - Admin Panel Styles
   Inspired by WordPress admin
   ===================================================== */

:root {
    --admin-primary: #1d2327;
    --admin-secondary: #2271b1;
    --admin-accent: #d63638;
    --admin-success: #00a32a;
    --admin-warning: #dba617;
    --admin-bg: #f0f0f1;
    --admin-card-bg: #ffffff;
    --admin-border: #c3c4c7;
    --admin-border-light: #e0e0e0;
    --admin-text: #1d2327;
    --admin-text-light: #646970;
    --admin-text-muted: #a7aaad;
    --admin-sidebar-bg: #1d2327;
    --admin-sidebar-text: #f0f0f1;
    --admin-topbar-bg: #1d2327;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
    --shadow: 0 2px 4px rgba(0,0,0,0.1);
    --radius: 4px;
}

* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", "Noto Sans SC", sans-serif;
    font-feature-settings: "cv11", "ss01", "ss03";
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    color: var(--admin-text);
    background: var(--admin-bg);
    font-size: 14px;
    line-height: 1.5;
}
a { color: var(--admin-secondary); text-decoration: none; }
a:hover { color: #135e96; }
img { max-width: 100%; }
code { background: #f6f7f7; padding: 2px 6px; border-radius: 3px; font-size: 13px; }

/* ============== Login Page ============== */
.login-page {
    background: linear-gradient(135deg, #006B2C 0%, #009944 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-box {
    background: #fff;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}
.login-header { text-align: center; margin-bottom: 30px; }
.login-header i { font-size: 36px; color: var(--admin-secondary); }
.login-header h1 { font-size: 22px; margin: 10px 0 5px; color: var(--admin-primary); }
.login-header p { color: var(--admin-text-light); margin: 0; }
.login-form .form-group { width: 100%; margin-bottom: 18px; }
.login-form label { display: block; font-weight: 500; margin-bottom: 6px; }
.login-form .form-control {
    width: 100%;
    box-sizing: border-box;
    padding: 10px 14px;
    border: 1px solid var(--admin-border);
    border-radius: 4px;
    font-size: 14px;
    font-family: inherit;
    display: block;
}
.login-form .form-control:focus { border-color: var(--admin-secondary); outline: none; box-shadow: 0 0 0 1px var(--admin-secondary); }
.btn-login {
    width: 100%;
    box-sizing: border-box;
    display: block;
    padding: 12px;
    background: var(--admin-secondary);
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
}
.btn-login:hover { background: #135e96; }
.login-footer { text-align: center; margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--admin-border-light); }
.login-footer a { color: var(--admin-text-light); font-size: 13px; }

/* ============== Layout ============== */
.admin-wrapper { display: flex; flex-direction: column; min-height: 100vh; }
.admin-topbar {
    background: var(--admin-topbar-bg);
    color: #fff;
    height: 50px;
    display: flex;
    align-items: center;
    padding: 0 20px;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}
.sidebar-toggle { background: none; border: none; color: #fff; font-size: 18px; cursor: pointer; padding: 5px 10px; }
.admin-logo { color: #fff; font-size: 16px; font-weight: 600; margin-left: 10px; }
.admin-logo i { color: var(--admin-accent); margin-right: 6px; }
.admin-logo span { font-weight: 300; opacity: 0.8; font-size: 14px; margin-left: 4px; }
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 20px; font-size: 13px; }
.topbar-link { color: rgba(255,255,255,0.8); }
.topbar-link:hover { color: #fff; }
.topbar-user { display: flex; align-items: center; gap: 8px; color: rgba(255,255,255,0.9); }
.topbar-user i { font-size: 18px; color: var(--admin-accent); }
.user-role { background: var(--admin-secondary); color: #fff; padding: 1px 8px; border-radius: 3px; font-size: 11px; text-transform: uppercase; }

.admin-wrapper { display: grid; grid-template-columns: 220px 1fr; grid-template-rows: 50px 1fr; grid-template-areas: "topbar topbar" "sidebar main"; }
.admin-topbar { grid-area: topbar; }
.admin-sidebar {
    grid-area: sidebar;
    background: var(--admin-sidebar-bg);
    color: var(--admin-sidebar-text);
    overflow-y: auto;
    max-height: calc(100vh - 50px);
    position: sticky; top: 50px;
}
.admin-sidebar nav ul { padding: 10px 0; }
.admin-sidebar .menu-section { padding: 15px 20px 5px; font-size: 11px; text-transform: uppercase; color: rgba(255,255,255,0.4); letter-spacing: 1px; }
.admin-sidebar nav li a {
    display: flex; align-items: center; gap: 10px;
    padding: 9px 20px;
    color: rgba(255,255,255,0.8);
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.2s;
}
.admin-sidebar nav li a:hover { background: rgba(255,255,255,0.05); color: #fff; }
.admin-sidebar nav li.active a { background: var(--admin-secondary); color: #fff; border-left-color: var(--admin-accent); }
.admin-sidebar nav li a i { width: 18px; }
.admin-sidebar .count { margin-left: auto; background: rgba(255,255,255,0.1); padding: 1px 8px; border-radius: 10px; font-size: 11px; }
.admin-sidebar .count.badge { background: var(--admin-accent); color: #fff; }

.admin-main { grid-area: main; padding: 20px 30px; min-width: 0; }
.admin-content { max-width: 1400px; margin: 0 auto; }

/* ============== Page Header ============== */
.page-header {
    display: flex; justify-content: space-between; align-items: center;
    margin-bottom: 20px; flex-wrap: wrap; gap: 15px;
}
.page-header h1 { font-size: 23px; font-weight: 400; margin: 0 0 5px; color: var(--admin-text); }
.page-header p { margin: 0; color: var(--admin-text-light); font-size: 13px; }

/* ============== Cards ============== */
.card {
    background: var(--admin-card-bg);
    border: 1px solid var(--admin-border-light);
    border-radius: var(--radius);
    margin-bottom: 20px;
    box-shadow: var(--shadow-sm);
}
.card-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--admin-border-light);
    display: flex; justify-content: space-between; align-items: center;
    background: #fafafa;
    border-radius: var(--radius) var(--radius) 0 0;
}
.card-header h3 { margin: 0; font-size: 14px; font-weight: 600; color: var(--admin-text); }
.card-header h3 i { color: var(--admin-text-light); margin-right: 6px; }
.card-link { font-size: 13px; }
.card-body { padding: 20px; }

/* ============== Stats Grid ============== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}
.stat-card {
    background: #fff;
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--admin-border-light);
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 50px; height: 50px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 20px;
    flex-shrink: 0;
}
.stat-blue { border-top: 3px solid #2271b1; }
.stat-blue .stat-icon { background: #2271b1; }
.stat-green { border-top: 3px solid #00a32a; }
.stat-green .stat-icon { background: #00a32a; }
.stat-orange { border-top: 3px solid #00a32a; }
.stat-orange .stat-icon { background: #00a32a; }
.stat-purple { border-top: 3px solid #826eb4; }
.stat-purple .stat-icon { background: #826eb4; }
.stat-red { border-top: 3px solid #d63638; }
.stat-red .stat-icon { background: #d63638; }
.stat-teal { border-top: 3px solid #008080; }
.stat-teal .stat-icon { background: #008080; }
.stat-num { font-size: 26px; font-weight: 600; line-height: 1; }
.stat-label { color: var(--admin-text-light); font-size: 13px; }
.unread-badge { background: var(--admin-accent); color: #fff; padding: 2px 8px; border-radius: 10px; font-size: 11px; margin-left: 8px; vertical-align: middle; }

.dashboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }

/* ============== Activity List ============== */
.activity-list li { padding: 8px 0; border-bottom: 1px solid var(--admin-border-light); display: flex; align-items: center; gap: 10px; font-size: 13px; }
.activity-list li:last-child { border-bottom: none; }
.activity-list li i { color: var(--admin-secondary); font-size: 6px; }
.activity-time { margin-left: auto; color: var(--admin-text-muted); font-size: 12px; }

/* ============== Form Layout ============== */
.form-grid { display: grid; grid-template-columns: 1fr 320px; gap: 20px; }
.form-main, .form-side { min-width: 0; }
@media (max-width: 1024px) { .form-grid { grid-template-columns: 1fr; } }

.form-group { margin-bottom: 15px; }
.form-group label { display: block; font-weight: 500; margin-bottom: 6px; font-size: 13px; }
.form-group small.text-muted { font-weight: normal; color: var(--admin-text-muted); }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 15px; }
@media (max-width: 768px) { .form-row { grid-template-columns: 1fr; gap: 0; } }
.form-control {
    width: 100%;
    padding: 8px 10px;
    border: 1px solid var(--admin-border);
    border-radius: 3px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    transition: all 0.15s;
}
.form-control:focus { border-color: var(--admin-secondary); outline: none; box-shadow: 0 0 0 1px var(--admin-secondary); }
textarea.form-control { resize: vertical; min-height: 80px; font-family: inherit; }
.required { color: var(--admin-accent); }

.checkbox-label {
    display: flex; align-items: center; gap: 8px;
    cursor: pointer; padding: 4px 0;
    font-size: 13px;
}
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.form-actions { display: flex; gap: 10px; padding-top: 15px; border-top: 1px solid var(--admin-border-light); margin-top: 20px; }

/* ============== Buttons ============== */
.btn {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 6px 14px;
    border-radius: 3px;
    font-size: 13px;
    font-weight: 500;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all 0.15s;
    text-decoration: none;
    background: #f6f7f7;
    color: var(--admin-text);
    border-color: var(--admin-border);
}
.btn:hover { background: #e9eaec; }
.btn-primary { background: var(--admin-secondary); color: #fff; border-color: var(--admin-secondary); }
.btn-primary:hover { background: #135e96; border-color: #135e96; color: #fff; }
.btn-secondary { background: #f6f7f7; }
.btn-danger { background: var(--admin-accent); color: #fff; border-color: var(--admin-accent); }
.btn-danger:hover { background: #b32d2e; border-color: #b32d2e; color: #fff; }
.btn-link { background: none; border: none; color: var(--admin-secondary); }
.btn-sm { padding: 3px 8px; font-size: 12px; }
.btn-lg { padding: 10px 22px; font-size: 15px; }
.btn-block { display: flex; width: 100%; justify-content: center; }

/* ============== Tables ============== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}
.data-table th, .data-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--admin-border-light);
    font-size: 13px;
    vertical-align: middle;
}
.data-table th {
    background: #f6f7f7;
    font-weight: 600;
    color: var(--admin-text);
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
.data-table tr:hover { background: #fafafa; }
.data-table .empty-row { text-align: center; padding: 40px; color: var(--admin-text-muted); }
.row-unread { background: #fff8e1; }
.row-unread:hover { background: #fff3cd; }

.thumb-sm { width: 40px; height: 40px; object-fit: cover; border-radius: 3px; }
.thumb-placeholder { background: #f0f0f1; color: #ccc; display: flex; align-items: center; justify-content: center; font-size: 16px; }

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

/* ============== Tags ============== */
.tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    background: #f0f0f1;
    color: var(--admin-text);
}
.tag-blue { background: #e3f2fd; color: #1565c0; }
.tag-green { background: #e8f5e9; color: #2e7d32; }
.tag-red { background: #ffebee; color: #c62828; }
.tag-orange { background: #e8f5e9; color: #1b5e20; }
.tag-gray { background: #f0f0f1; color: var(--admin-text-light); }

/* ============== Filter Bar ============== */
.filter-bar { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; flex-wrap: wrap; }
.filter-bar .form-control { width: auto; min-width: 200px; }
.bulk-actions { display: flex; gap: 10px; align-items: center; margin-bottom: 15px; }
.bulk-actions select { width: auto; }

.filter-tabs { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 1px solid var(--admin-border-light); }
.filter-tabs a { padding: 8px 16px; color: var(--admin-text); border-bottom: 2px solid transparent; font-size: 13px; }
.filter-tabs a:hover { color: var(--admin-secondary); }
.filter-tabs a.active { color: var(--admin-secondary); border-bottom-color: var(--admin-secondary); font-weight: 500; }

.tabs-nav { display: flex; gap: 5px; margin-bottom: 20px; border-bottom: 1px solid var(--admin-border-light); }
.tabs-nav .tab-link { padding: 10px 16px; color: var(--admin-text); border-bottom: 2px solid transparent; font-size: 13px; }
.tabs-nav .tab-link:hover { color: var(--admin-secondary); }
.tabs-nav .tab-link.active { color: var(--admin-secondary); border-bottom-color: var(--admin-secondary); font-weight: 500; }

/* ============== Pagination ============== */
.pagination { display: flex; gap: 5px; justify-content: center; margin-top: 20px; }
.pagination .page-link {
    padding: 6px 12px;
    border: 1px solid var(--admin-border);
    border-radius: 3px;
    color: var(--admin-secondary);
    font-size: 13px;
}
.pagination .page-link:hover { background: #f6f7f7; }
.pagination .page-link.active { background: var(--admin-secondary); color: #fff; border-color: var(--admin-secondary); }

/* ============== Image Preview ============== */
.image-preview { margin-bottom: 10px; padding: 5px; border: 1px solid var(--admin-border-light); border-radius: 3px; display: inline-block; max-width: 100%; }
.image-preview img { max-width: 100%; max-height: 250px; display: block; }

/* ============== Flash Messages ============== */
.flash {
    padding: 12px 16px;
    border-radius: 4px;
    margin-bottom: 15px;
    border-left: 4px solid;
    font-size: 14px;
}
.flash-success { background: #edfaef; border-color: var(--admin-success); color: #13532f; }
.flash-error { background: #fcf0f1; border-color: var(--admin-accent); color: #8b1d1f; }
.flash-warning { background: #fcf9e8; border-color: var(--admin-warning); color: #6f5d00; }
.flash-info { background: #f0f6fc; border-color: var(--admin-secondary); color: #0c3b66; }

/* ============== Article List (sidebar) ============== */
.article-list li { padding: 8px 0; border-bottom: 1px solid var(--admin-border-light); }
.article-list li:last-child { border-bottom: none; }
.article-list li a { color: var(--admin-text); font-size: 13px; }
.article-list li a:hover { color: var(--admin-secondary); }
.article-meta { font-size: 12px; color: var(--admin-text-muted); margin-left: 8px; }

/* ============== Media Grid ============== */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 15px; }
.media-item {
    border: 1px solid var(--admin-border-light);
    border-radius: 4px;
    overflow: hidden;
    background: #fafafa;
}
.media-item img { width: 100%; height: 130px; object-fit: cover; display: block; }
.media-file-icon { height: 130px; display: flex; align-items: center; justify-content: center; font-size: 36px; color: #aaa; }
.media-info { padding: 8px; background: #fff; }
.media-name { font-size: 12px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.media-size { font-size: 11px; color: var(--admin-text-muted); }
.media-actions { display: flex; gap: 4px; margin-top: 6px; }

/* ============== Message Detail ============== */
.message-detail { padding: 20px; background: #fafafa; border-radius: 4px; margin-bottom: 20px; }
.message-meta p { margin-bottom: 6px; font-size: 13px; }
.message-body { margin-top: 20px; padding-top: 20px; border-top: 1px solid var(--admin-border-light); }
.message-body h4 { margin-top: 0; }

/* ============== Product Gallery Manager ============== */
.gallery-manager {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    margin-bottom: 16px;
}
.gallery-item {
    position: relative;
    aspect-ratio: 1;
    border: 1px solid var(--admin-border);
    border-radius: 4px;
    overflow: hidden;
    background: #f6f7f7;
    transition: opacity 0.2s;
}
.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.gallery-remove {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: none;
    background: rgba(220, 53, 69, 0.92);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    transition: background 0.15s;
}
.gallery-remove:hover { background: #c82333; }
.gallery-item-removing { opacity: 0.35; pointer-events: none; }
.gallery-item-new {
    border: 2px dashed var(--admin-primary);
    background: #f0f6fc;
}

.gallery-add { margin-top: 12px; }
.gallery-dropzone {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 28px 16px;
    border: 2px dashed var(--admin-border);
    border-radius: 6px;
    background: #fafafa;
    color: var(--admin-text-light);
    cursor: pointer;
    transition: all 0.2s;
    text-align: center;
}
.gallery-dropzone:hover {
    border-color: var(--admin-primary);
    background: #f0f6fc;
    color: var(--admin-primary);
}
.gallery-dropzone i { font-size: 28px; }
.gallery-dropzone input[type="file"] { display: none; }
.gallery-preview {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 10px;
    margin-top: 12px;
}
.empty-hint {
    color: var(--admin-text-muted);
    font-size: 13px;
    font-style: italic;
    padding: 12px;
    background: #f6f7f7;
    border-radius: 4px;
    text-align: center;
    margin: 0;
}
.card-header .muted { color: var(--admin-text-muted); font-weight: normal; font-size: 13px; }

/* ============== Empty State ============== */
.empty-text { color: var(--admin-text-muted); text-align: center; padding: 30px 20px; }

/* ============== Responsive ============== */
@media (max-width: 768px) {
    .admin-wrapper { grid-template-columns: 1fr; grid-template-areas: "topbar" "main"; }
    .admin-sidebar { position: fixed; left: -220px; top: 50px; bottom: 0; z-index: 99; width: 220px; max-height: none; transition: left 0.3s; }
    .admin-sidebar.open { left: 0; box-shadow: 5px 0 20px rgba(0,0,0,0.2); }
    .admin-main { padding: 15px; }
    .dashboard-grid { grid-template-columns: 1fr; }
    .topbar-link { display: none; }
    .topbar-user span:first-of-type { display: none; }
    .stats-grid { grid-template-columns: 1fr 1fr; }
}
