/* ============================================================
   ACE Supplier Portal — ace-website Design System
   ACE Blue (#2C3C66) + ACE Orange (#F08519)
   Fonts: Manrope (headlines), Inter (body)
   ============================================================ */

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

:root {
    --ace-blue: #2C3C66;
    --ace-orange: #F08519;
    --ace-orange-dark: #d9750f;
    --ace-blue-dark: #1f2d4d;
    --ace-blue-light: #3d5080;
    --ace-blue-50: #f0f3f8;
    --ace-blue-100: #dde3ef;
    --ace-orange-50: #fef6ed;
    --ace-orange-100: #fde8d0;
    --background: #f8f9ff;
    --surface: #ffffff;
    --text: #334155;
    --text-muted: #64748b;
    --border: #e2e8f0;
    --border-hover: rgba(240, 133, 25, 0.4);
    --shadow-sm: 0 1px 3px rgba(44, 60, 102, 0.08);
    --shadow-md: 0 4px 16px rgba(44, 60, 102, 0.1);
    --shadow-lg: 0 8px 32px rgba(44, 60, 102, 0.12);
    --radius: 12px;
    --radius-sm: 8px;
    --radius-lg: 16px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Microsoft YaHei', sans-serif;
    background: var(--background);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

h1, h2, h3, h4, h5, h6, .brand, .section-title {
    font-family: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ===== NAV BAR (ace-website light style) ===== */
.top-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(12px);
    padding: 0 24px;
    height: 64px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    border-bottom: 1px solid var(--border);
    box-shadow: 0 1px 4px rgba(44, 60, 102, 0.06);
}
.nav-left { display: flex; align-items: center; gap: 12px; }
.nav-logo { height: 36px; width: auto; }
.brand-link { text-decoration: none; display: flex; align-items: baseline; gap: 6px; }
.brand { font-weight: 700; font-size: 16px; color: var(--ace-blue); letter-spacing: -0.3px; }
.brand-en { font-size: 11px; color: var(--text-muted); font-weight: 500; letter-spacing: 0.3px; }
.nav-right { display: flex; align-items: center; gap: 16px; font-size: 13px; flex-wrap: wrap; }
.user-info { color: var(--ace-blue); font-weight: 500; }
.dept { color: var(--text-muted); font-weight: 400; }
.realm-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}
.realm-badge.employee { background: rgba(44, 60, 102, 0.08); color: var(--ace-blue); }
.realm-badge.customer { background: rgba(240, 133, 25, 0.1); color: var(--ace-orange); }
.admin-link {
    color: var(--ace-orange);
    text-decoration: none;
    font-weight: 600;
    font-size: 13px;
    padding: 6px 14px;
    border: 1.5px solid rgba(240, 133, 25, 0.3);
    border-radius: 8px;
    transition: all 0.3s;
}
.admin-link:hover {
    background: var(--ace-orange);
    color: white;
    border-color: var(--ace-orange);
}
.logout-link { color: var(--text-muted); text-decoration: none; font-size: 13px; padding: 6px 10px; border-radius: 6px; transition: all 0.2s; }
.logout-link:hover { color: var(--ace-blue); background: rgba(44, 60, 102, 0.04); }
.back-link { color: var(--text-muted); text-decoration: none; font-size: 13px; font-weight: 500; transition: color 0.2s; }
.back-link:hover { color: var(--ace-blue); }

/* ===== MOBILE NAV ===== */
@media (max-width: 768px) {
    .top-nav { padding: 0 12px; height: auto; min-height: 56px; flex-wrap: wrap; gap: 4px; padding: 8px 12px; }
    .nav-logo { height: 28px; }
    .brand { font-size: 14px; }
    .brand-en { display: none; }
    .nav-right { gap: 8px; font-size: 12px; }
    .admin-link { padding: 4px 10px; font-size: 12px; }
}

/* ===== ANNOUNCEMENTS ===== */
.announcements {
    background: var(--ace-orange-50);
    border-bottom: 1px solid var(--ace-orange-100);
}
.announcement {
    padding: 12px 32px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text);
}
.announcement.pinned { background: rgba(240, 133, 25, 0.06); }
.announcement strong { color: var(--ace-blue); }
.ann-icon { font-size: 14px; }

/* ===== CONTAINER ===== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 32px 24px;
}

/* ===== SEARCH ===== */
.search-bar { margin-bottom: 36px; }
.search-input {
    width: 100%;
    max-width: 420px;
    padding: 12px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--surface);
    color: var(--text);
    transition: all 0.3s;
}
.search-input::placeholder { color: var(--text-muted); }
.search-input:focus {
    outline: none;
    border-color: var(--ace-orange);
    box-shadow: 0 0 0 3px rgba(240, 133, 25, 0.1);
}

/* ===== SECTIONS ===== */
.section { margin-bottom: 44px; }
.section-title {
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: var(--text-muted);
    margin-bottom: 18px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 10px;
}
.section-title::before {
    content: '';
    display: inline-block;
    width: 3px;
    height: 14px;
    background: var(--ace-orange);
    border-radius: 2px;
}

/* ===== CATEGORY SUB-GROUP ===== */
.category-group { margin-bottom: 24px; }
.category-group:last-child { margin-bottom: 0; }
.category-header { display: flex; align-items: center; gap: 6px; margin-bottom: 12px; }
.category-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--ace-blue);
    padding-left: 2px;
}
.pin-form { display: inline; }
.pin-btn {
    background: none; border: none; font-size: 14px; cursor: pointer;
    opacity: 0.3; transition: all 0.25s; padding: 2px; line-height: 1;
    filter: grayscale(1);
}
.pin-btn:hover { opacity: 0.7; filter: grayscale(0); }
.pin-btn.active { opacity: 1; filter: grayscale(0); }

/* ===== APP GRID ===== */
.app-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 16px;
}

.app-card {
    background: var(--surface);
    padding: 28px 18px 22px;
    border-radius: var(--radius);
    text-align: center;
    border: 1px solid var(--border);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.app-card::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 2px;
    background: linear-gradient(90deg, var(--ace-orange), var(--ace-orange-dark));
    transform: scaleX(0);
    transition: transform 0.3s ease;
}
.app-card:hover {
    border-color: var(--border-hover);
    transform: translateY(-3px);
    box-shadow: var(--shadow-lg);
}
.app-card:hover::after { transform: scaleX(1); }

.app-link { text-decoration: none; color: inherit; display: block; }
.app-icon {
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s;
}
.app-icon i {
    width: 36px;
    height: 36px;
    color: var(--ace-blue);
    stroke-width: 1.5;
}
.app-icon-img {
    width: 44px;
    height: 44px;
    object-fit: contain;
    border-radius: 10px;
}
.activity-icon-img {
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 4px;
}
.app-card:hover .app-icon { transform: scale(1.08); }
.app-card:hover .app-icon i { color: var(--ace-orange); }

/* Offline card */
.app-card-offline {
    opacity: 0.5;
    filter: grayscale(0.6);
}
.app-card-offline:hover {
    transform: none;
    border-color: var(--border);
    box-shadow: var(--shadow-sm);
}
.app-card-offline:hover::after { transform: scaleX(0); }
.app-card-offline:hover .app-icon { transform: none; }
.app-card-offline:hover .app-icon i { color: var(--text-muted); }
.app-link-disabled { cursor: default; }
.app-offline-tag {
    display: inline-block;
    margin-top: 8px;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 0.5px;
    background: rgba(239, 68, 68, 0.1);
    color: #b91c1c;
}

.app-name { font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 14px; color: var(--ace-blue); margin-bottom: 5px; letter-spacing: -0.2px; }
.app-desc { font-size: 11px; color: var(--text-muted); line-height: 1.4; }

/* ===== FAVORITES ===== */
.fav-form { position: absolute; top: 8px; right: 8px; }
.fav-btn {
    background: none; border: none; font-size: 18px; cursor: pointer;
    color: var(--text-muted); padding: 4px; transition: all 0.25s; line-height: 1;
}
.fav-btn:hover { color: var(--ace-orange); transform: scale(1.2); }
.fav-btn.active { color: var(--ace-orange); }

/* ===== ACTIVITY ===== */
.activity-list {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    overflow: hidden;
}
.activity-item {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
    color: var(--text);
}
.activity-item:last-child { border-bottom: none; }
.activity-item:hover { background: var(--ace-blue-50); }
.activity-item strong { color: var(--ace-blue); }
.activity-icon { font-size: 18px; }
.activity-time { margin-left: auto; color: var(--text-muted); font-size: 12px; }

/* ===== EMPTY STATE ===== */
.empty-state { text-align: center; padding: 80px 20px; color: var(--text-muted); }
.empty-state p { margin-bottom: 8px; }
.empty-state a { color: var(--ace-orange); font-weight: 600; text-decoration: none; }
.empty-state a:hover { text-decoration: underline; }

/* ============================================================
   ADMIN PAGES
   ============================================================ */
.admin-container { max-width: 960px; margin: 0 auto; padding: 32px 24px; }
.admin-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 24px; }
.admin-header h1 { font-size: 22px; font-weight: 700; color: var(--ace-blue); letter-spacing: -0.3px; }

/* ===== BUTTONS ===== */
.btn {
    display: inline-block; padding: 8px 18px; border-radius: var(--radius-sm);
    font-size: 13px; font-weight: 600; font-family: 'Inter', sans-serif; text-decoration: none;
    border: none; cursor: pointer; transition: all 0.25s; letter-spacing: -0.1px;
}
.btn-primary {
    background: var(--ace-orange);
    color: white;
    box-shadow: 0 2px 8px rgba(240, 133, 25, 0.25);
}
.btn-primary:hover { background: var(--ace-orange-dark); box-shadow: 0 4px 16px rgba(240, 133, 25, 0.3); transform: translateY(-1px); }
.btn-danger { background: #ef4444; color: white; }
.btn-danger:hover { background: #dc2626; }
.btn-secondary {
    background: var(--surface);
    color: var(--ace-blue);
    border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--ace-blue-50); border-color: var(--ace-blue); }
.btn-sm { padding: 5px 12px; font-size: 12px; }

/* ===== TABLE ===== */
.data-table {
    width: 100%; border-collapse: collapse;
    background: var(--surface);
    border-radius: var(--radius); overflow: hidden;
    border: 1px solid var(--border);
}
.data-table th {
    background: var(--ace-blue-50);
    color: var(--ace-blue);
    text-align: left; padding: 12px 16px;
    font-size: 11px; text-transform: uppercase; letter-spacing: 1px; font-weight: 600;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--border);
    font-size: 13px; color: var(--text);
}
.data-table td strong { color: var(--ace-blue); }
.data-table td a { color: var(--ace-orange); font-size: 12px; }
.data-table tr:hover td { background: var(--ace-orange-50); }

/* ===== FORMS ===== */
.form-group { margin-bottom: 20px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; color: var(--ace-blue); margin-bottom: 6px; }
.form-group input,
.form-group textarea,
.form-group select {
    width: 100%; padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 14px; font-family: inherit;
    color: var(--text);
    background: var(--surface);
    transition: all 0.25s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--ace-orange);
    box-shadow: 0 0 0 3px rgba(240, 133, 25, 0.1);
}
.form-group select option { background: white; color: var(--text); }
.form-group textarea { resize: vertical; min-height: 100px; }
.form-group small { display: block; margin-top: 4px; color: var(--text-muted); font-size: 12px; }
.form-card {
    background: var(--surface);
    padding: 28px; border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}
.form-actions { display: flex; gap: 10px; margin-top: 24px; }

/* ===== BADGES ===== */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 600; letter-spacing: 0.2px; }
.badge-green { background: rgba(34, 197, 94, 0.12); color: #15803d; }
.badge-red { background: rgba(239, 68, 68, 0.1); color: #b91c1c; }
.badge-blue { background: rgba(44, 60, 102, 0.1); color: var(--ace-blue); }

/* ===== ICON GRID ===== */
.icon-grid {
    display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px;
    max-height: 260px; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius-sm);
    padding: 10px; background: var(--background);
}
.icon-option {
    display: flex; flex-direction: column; align-items: center; gap: 4px;
    padding: 10px 4px; cursor: pointer; border-radius: 8px; transition: all 0.15s;
}
.icon-option i { width: 24px; height: 24px; color: var(--text-muted); stroke-width: 1.5; }
.icon-option span { font-size: 10px; color: var(--text-muted); }
.icon-option:hover { background: var(--ace-orange-50); }
.icon-option:hover i { color: var(--ace-orange); }
.icon-option.selected { background: var(--ace-orange-100); outline: 2px solid var(--ace-orange); }
.icon-option.selected i { color: var(--ace-orange); }
.dept-checks { display: flex; flex-wrap: wrap; gap: 8px; }
.dept-check {
    display: flex; align-items: center; gap: 6px;
    background: var(--background); padding: 7px 14px;
    border-radius: var(--radius-sm); border: 1px solid var(--border);
    font-size: 13px; cursor: pointer; transition: all 0.2s; color: var(--ace-blue);
}
.dept-check:hover { border-color: var(--ace-blue); background: var(--ace-blue-50); }
.dept-check input { cursor: pointer; accent-color: var(--ace-orange); }
.role-checks { display: flex; gap: 16px; }
.role-check { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--ace-blue); }
.role-check input { accent-color: var(--ace-orange); }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
    .top-nav { padding: 0 16px; }
    .container { padding: 20px 16px; }
    .app-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 12px; }
    .nav-right { gap: 12px; }
    .dept { display: none; }
    .app-card { padding: 22px 14px 18px; }
}

/* ===== FOOTER (ace-website style) ===== */
.site-footer {
    background: #4A5A75;
    color: #94a3b8;
    padding: 60px 0 0;
    margin-top: 80px;
    font-size: 14px;
    line-height: 1.7;
}
.footer-grid {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 24px;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 48px;
}
.footer-logo {
    height: 40px;
    filter: brightness(0) invert(1);
    margin-bottom: 16px;
}
.footer-desc { color: #94a3b8; margin-bottom: 24px; }
.footer-heading { color: #ffffff; font-family: 'Manrope', sans-serif; font-weight: 700; font-size: 14px; margin-bottom: 16px; }
.footer-links { list-style: none; }
.footer-links li { margin-bottom: 8px; }
.footer-links a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }
.footer-links a:hover { color: var(--ace-orange); }
.footer-contact { list-style: none; }
.footer-contact li { margin-bottom: 16px; }
.footer-contact a { color: #94a3b8; text-decoration: none; transition: color 0.2s; }
.footer-contact a:hover { color: var(--ace-orange); }
.footer-label { display: block; color: #ffffff; font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1.5px; margin-bottom: 4px; }
.footer-bottom {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px 24px;
    margin-top: 40px;
    border-top: 1px solid rgba(255,255,255,0.1);
    text-align: center;
}
.footer-bottom p { color: #64748b; font-size: 12px; }

@media (max-width: 768px) {
    .footer-grid { grid-template-columns: 1fr; gap: 32px; }
    .site-footer { padding-top: 40px; margin-top: 40px; }
}
