/**
 * Shirts Plus CRM — Customer Portal Styles
 * Clean, mobile-first design with brand colors.
 */

:root {
    --sp-cyan:    #1BBFC7;
    --sp-pink:    #E91E8C;
    --sp-yellow:  #FDD835;
    --sp-green:   #7CB342;
    --sp-red:     #E53935;
    --sp-dark:    #2C2C2C;
    --sp-gray:    #888888;
    --sp-light:   #F8F9FA;
    --sp-white:   #FFFFFF;
    --sp-border:  #E8E8E8;
    --sp-font:    -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    --sp-radius:  8px;
    --sp-shadow:  0 2px 8px rgba(0,0,0,0.06);
}

/* ─── Reset / Base ──────────────────────────────────────────────────────────── */
.sp-portal {
    font-family: var(--sp-font);
    color: var(--sp-dark);
    font-size: 14px;
    line-height: 1.6;
    max-width: 960px;
    margin: 0 auto;
    padding: 0 16px;
}

.sp-portal * { box-sizing: border-box; }

.sp-portal a {
    color: var(--sp-pink);
    text-decoration: none;
    font-weight: bold;
}

.sp-portal a:hover {
    text-decoration: underline;
}

/* ─── Page Header ───────────────────────────────────────────────────────────── */
.sp-portal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 12px;
    border-bottom: 3px solid var(--sp-cyan);
}

.sp-portal-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--sp-dark);
    font-family: var(--sp-font);
}

/* ─── Cards ─────────────────────────────────────────────────────────────────── */
.sp-card {
    background: var(--sp-white);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: var(--sp-shadow);
    transition: box-shadow 0.2s;
}

.sp-card:hover {
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
}

.sp-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.sp-card-title {
    font-size: 16px;
    font-weight: bold;
    color: var(--sp-dark);
}

.sp-card-meta {
    font-size: 12px;
    color: var(--sp-gray);
}

/* ─── Status Badges ─────────────────────────────────────────────────────────── */
.sp-badge {
    display: inline-block;
    padding: 4px 12px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-radius: 20px;
    font-family: var(--sp-font);
}

.sp-badge--draft     { background: #EEEEEE; color: #666; }
.sp-badge--sent      { background: #E3F2FD; color: #1565C0; }
.sp-badge--viewed    { background: #FFF8E1; color: #F57F17; }
.sp-badge--approved  { background: #E8F5E9; color: #2E7D32; }
.sp-badge--paid      { background: #E8F5E9; color: #2E7D32; }
.sp-badge--declined  { background: #FFEBEE; color: #C62828; }
.sp-badge--overdue   { background: #FFEBEE; color: #C62828; }
.sp-badge--active    { background: #E0F7FA; color: #00838F; }
.sp-badge--completed { background: #F3E5F5; color: #6A1B9A; }
.sp-badge--pending   { background: #FFF8E1; color: #F57F17; }

/* ─── Buttons ───────────────────────────────────────────────────────────────── */
.sp-btn {
    display: inline-block;
    padding: 10px 24px;
    font-family: var(--sp-font);
    font-size: 13px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    text-decoration: none;
    transition: background 0.2s, transform 0.1s;
}

.sp-btn:hover {
    transform: translateY(-1px);
    text-decoration: none;
}

.sp-btn:active {
    transform: translateY(0);
}

.sp-btn--primary {
    background: var(--sp-cyan);
    color: white;
}

.sp-btn--primary:hover { background: #17a8b0; color: white; }

.sp-btn--pink {
    background: var(--sp-pink);
    color: white;
}

.sp-btn--pink:hover { background: #d01578; color: white; }

.sp-btn--green {
    background: var(--sp-green);
    color: white;
}

.sp-btn--green:hover { background: #689f38; color: white; }

.sp-btn--outline {
    background: transparent;
    border: 2px solid var(--sp-cyan);
    color: var(--sp-cyan);
}

.sp-btn--outline:hover {
    background: var(--sp-cyan);
    color: white;
}

.sp-btn--sm {
    padding: 6px 16px;
    font-size: 11px;
}

.sp-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* ─── Tables (Responsive) ───────────────────────────────────────────────────── */
.sp-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sp-table {
    width: 100%;
    border-collapse: collapse;
    font-family: var(--sp-font);
    font-size: 13px;
}

.sp-table th {
    background: var(--sp-light);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sp-gray);
    padding: 10px 12px;
    text-align: left;
    border-bottom: 2px solid var(--sp-border);
}

.sp-table td {
    padding: 12px;
    border-bottom: 1px solid var(--sp-border);
    vertical-align: middle;
}

.sp-table tr:hover td {
    background: var(--sp-light);
}

.sp-table code {
    background: #f0f0f0;
    padding: 2px 6px;
    font-size: 12px;
    color: var(--sp-pink);
}

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

.sp-form-group label {
    display: block;
    font-weight: bold;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--sp-gray);
    margin-bottom: 4px;
}

.sp-input,
.sp-textarea,
.sp-select {
    width: 100%;
    padding: 10px 14px;
    font-family: var(--sp-font);
    font-size: 14px;
    border: 2px solid var(--sp-border);
    border-radius: var(--sp-radius);
    background: var(--sp-white);
    transition: border-color 0.2s;
}

.sp-input:focus,
.sp-textarea:focus,
.sp-select:focus {
    border-color: var(--sp-cyan);
    outline: none;
    box-shadow: 0 0 0 3px rgba(27, 191, 199, 0.15);
}

.sp-textarea {
    min-height: 100px;
    resize: vertical;
}

/* ─── Shoutbox / Messages ───────────────────────────────────────────────────── */
.sp-messages {
    max-height: 400px;
    overflow-y: auto;
    padding: 16px;
    background: var(--sp-light);
    border-radius: var(--sp-radius);
    margin-bottom: 12px;
}

.sp-message {
    margin-bottom: 12px;
    padding: 10px 14px;
    border-radius: var(--sp-radius);
    max-width: 80%;
}

.sp-message--admin {
    background: var(--sp-cyan);
    color: white;
    margin-right: auto;
    border-bottom-left-radius: 2px;
}

.sp-message--customer {
    background: var(--sp-white);
    border: 1px solid var(--sp-border);
    margin-left: auto;
    border-bottom-right-radius: 2px;
}

.sp-message-meta {
    font-size: 10px;
    opacity: 0.7;
    margin-top: 4px;
}

.sp-message-input {
    display: flex;
    gap: 8px;
}

.sp-message-input .sp-input {
    flex: 1;
}

/* ─── File Upload ───────────────────────────────────────────────────────────── */
.sp-dropzone {
    border: 2px dashed var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 40px 20px;
    text-align: center;
    color: var(--sp-gray);
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
}

.sp-dropzone:hover,
.sp-dropzone.dragover {
    border-color: var(--sp-cyan);
    background: rgba(27, 191, 199, 0.05);
}

.sp-dropzone input[type="file"] {
    display: none;
}

/* ─── Proof Viewer ──────────────────────────────────────────────────────────── */
.sp-proof-image {
    max-width: 100%;
    height: auto;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    margin-bottom: 12px;
}

.sp-proof-actions {
    display: flex;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

/* ─── Invoice ───────────────────────────────────────────────────────────────── */
.sp-invoice-totals {
    text-align: right;
    margin-top: 16px;
    font-size: 14px;
}

.sp-invoice-totals .sp-total-line {
    display: flex;
    justify-content: flex-end;
    gap: 24px;
    padding: 4px 0;
}

.sp-invoice-totals .sp-total-line--grand {
    font-size: 18px;
    font-weight: bold;
    color: var(--sp-pink);
    border-top: 2px solid var(--sp-dark);
    padding-top: 8px;
    margin-top: 8px;
}

/* ─── Login Prompt ──────────────────────────────────────────────────────────── */
.sp-crm-login-prompt,
.sp-crm-error {
    text-align: center;
    padding: 40px 20px;
    background: var(--sp-light);
    border-radius: var(--sp-radius);
    color: var(--sp-gray);
}

.sp-crm-login-prompt a {
    color: var(--sp-pink);
}

/* ─── Loading Spinner ───────────────────────────────────────────────────────── */
.sp-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--sp-border);
    border-top-color: var(--sp-cyan);
    border-radius: 50%;
    animation: sp-spin 0.8s linear infinite;
}

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

/* ─── Mobile Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sp-portal { padding: 0 12px; }

    .sp-portal-header {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }

    .sp-card { padding: 16px; }

    .sp-card-header {
        flex-direction: column;
        gap: 8px;
        align-items: flex-start;
    }

    .sp-proof-actions {
        flex-direction: column;
    }

    .sp-proof-actions .sp-btn {
        width: 100%;
        text-align: center;
    }

    .sp-message { max-width: 90%; }

    .sp-invoice-totals { font-size: 13px; }

    .sp-table { font-size: 12px; }
    .sp-table th, .sp-table td { padding: 8px; }
}

@media (max-width: 480px) {
    .sp-portal-header h2 { font-size: 18px; }
    .sp-btn { padding: 10px 16px; font-size: 12px; width: 100%; text-align: center; }
}

/* ─── Portal Stats Grid ───────────────────────────────────────────────── */
.sp-portal-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

.sp-stat-card {
    background: var(--sp-white);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 20px;
    text-align: center;
    border-top: 3px solid var(--sp-cyan);
    transition: transform 0.15s;
}
.sp-stat-card:hover { transform: translateY(-2px); }
.sp-stat--pink { border-top-color: var(--sp-pink); }
.sp-stat--yellow { border-top-color: var(--sp-yellow); }
.sp-stat--green { border-top-color: var(--sp-green); }
.sp-stat--red { border-top-color: var(--sp-red); }

.sp-stat-number { font-size: 32px; font-weight: bold; color: var(--sp-dark); }
.sp-stat-label { font-size: 12px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--sp-gray); margin-top: 4px; }
.sp-stat-sub { font-size: 12px; margin-top: 4px; font-weight: bold; }

/* ─── Activity List ───────────────────────────────────────────────────── */
.sp-activity-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 0;
    border-bottom: 1px solid var(--sp-border);
    font-size: 13px;
}
.sp-activity-item:last-child { border-bottom: none; }
.sp-time { color: var(--sp-gray); font-size: 11px; margin-left: auto; white-space: nowrap; }

/* ─── Card Layouts ────────────────────────────────────────────────────── */
.sp-card--link { cursor: pointer; transition: transform 0.15s, box-shadow 0.15s; }
.sp-card--link:hover { transform: translateY(-1px); box-shadow: 0 4px 16px rgba(0,0,0,0.08); }

.sp-card-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.sp-card h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--sp-dark);
}

/* ─── List Items ──────────────────────────────────────────────────────── */
.sp-list-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid var(--sp-border);
    gap: 12px;
}
.sp-list-item:last-child { border-bottom: none; }

/* ─── Totals Block ────────────────────────────────────────────────────── */
.sp-totals {
    margin-top: 16px;
    padding-top: 12px;
    border-top: 1px solid var(--sp-border);
}
.sp-totals-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
    font-size: 14px;
}
.sp-totals-grand {
    border-top: 2px solid var(--sp-dark);
    margin-top: 8px;
    padding-top: 8px;
    font-size: 18px;
    font-weight: bold;
}

/* ─── Action Card ─────────────────────────────────────────────────────── */
.sp-action-card { border-top: 3px solid var(--sp-cyan); }
.sp-action-buttons {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* ─── Button Sizes ────────────────────────────────────────────────────── */
.sp-btn--lg { padding: 14px 28px; font-size: 16px; }
.sp-btn--yellow { background: #FF9800; color: #fff; border-color: #FF9800; }
.sp-btn--yellow:hover { background: #F57C00; }
.sp-btn--red { background: var(--sp-red); color: #fff; border-color: var(--sp-red); }
.sp-btn--red:hover { background: #C62828; }

/* ─── Badge Variants ──────────────────────────────────────────────────── */
.sp-badge--on-hold { background: #FFF3E0; color: #E65100; }
.sp-badge--cancelled { background: #ECEFF1; color: #546E7A; }
.sp-badge--revision-requested { background: #FFF3E0; color: #E65100; }
.sp-badge--partial { background: #E3F2FD; color: #1565C0; }
.sp-badge--in-production { background: #E8F5E9; color: #2E7D32; }

/* ─── Proof Gallery ───────────────────────────────────────────────────── */
.sp-proof-gallery { display: flex; flex-direction: column; gap: 16px; }
.sp-proof-image { text-align: center; }
.sp-proof-image img {
    max-width: 100%;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    cursor: pointer;
    transition: transform 0.15s;
}
.sp-proof-image img:hover { transform: scale(1.02); }
.sp-proof-image-name { font-size: 11px; color: var(--sp-gray); margin-top: 4px; }
.sp-proof-file { margin: 4px 0; }

/* ─── Messages ────────────────────────────────────────────────────────── */
.sp-messages-container { min-height: 200px; }

.sp-msg {
    margin-bottom: 10px;
    padding: 10px 14px;
    border-radius: var(--sp-radius);
    font-size: 13px;
}
.sp-msg--admin { background: #E0F7FA; border-left: 3px solid var(--sp-cyan); }
.sp-msg--customer { background: #FFF8E1; border-left: 3px solid var(--sp-yellow); }

.sp-msg-header {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
    color: var(--sp-gray);
}
.sp-msg-header strong { color: var(--sp-dark); }

.sp-message-input textarea {
    font-family: var(--sp-font);
    font-size: 13px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 10px;
}

/* ─── Upload Zone ─────────────────────────────────────────────────────── */
.sp-upload-zone {
    border: 2px dashed var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 32px;
    text-align: center;
    color: var(--sp-gray);
    transition: border-color 0.2s, background 0.2s;
    cursor: pointer;
}
.sp-upload-zone--active,
.sp-upload-zone:hover {
    border-color: var(--sp-cyan);
    background: #F0FDFE;
}
.sp-upload-link { color: var(--sp-pink); cursor: pointer; font-weight: bold; }

.sp-progress-bar {
    height: 6px;
    background: var(--sp-border);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 4px;
}
.sp-progress-fill {
    height: 100%;
    background: var(--sp-cyan);
    width: 0%;
    transition: width 0.3s;
}

/* ─── Public Form ─────────────────────────────────────────────────────── */
.sp-form-section {
    margin-bottom: 24px;
}
.sp-form-section h3 {
    margin: 0 0 12px;
    font-size: 15px;
    color: var(--sp-cyan);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sp-form-row {
    display: flex;
    gap: 16px;
    margin-bottom: 12px;
}

.sp-form-field {
    flex: 1;
}
.sp-form-field label {
    display: block;
    font-size: 12px;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    margin-bottom: 4px;
    color: var(--sp-dark);
}
.sp-form-field input,
.sp-form-field select,
.sp-form-field textarea {
    width: 100%;
    padding: 10px;
    font-family: var(--sp-font);
    font-size: 13px;
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    background: var(--sp-white);
}
.sp-form-field input:focus,
.sp-form-field select:focus,
.sp-form-field textarea:focus {
    border-color: var(--sp-cyan);
    outline: none;
    box-shadow: 0 0 0 2px rgba(27, 191, 199, 0.15);
}

.sp-loading-msg {
    text-align: center;
    color: var(--sp-gray);
    padding: 24px;
}

@media (max-width: 600px) {
    .sp-portal-stats { grid-template-columns: 1fr 1fr; }
    .sp-form-row { flex-direction: column; gap: 12px; }
    .sp-action-buttons { flex-direction: column; }
    .sp-card-row { flex-direction: column; align-items: flex-start; }
}

/* ─── Portal Navigation ───────────────────────────────────────────────────── */
.sp-portal-nav {
    display: flex;
    gap: 0;
    background: var(--sp-dark);
    border-radius: var(--sp-radius);
    margin-bottom: 24px;
    overflow: hidden;
    flex-wrap: wrap;
}
.sp-portal-nav-item {
    padding: 12px 18px;
    color: #ccc !important;
    font-weight: bold;
    text-decoration: none !important;
    font-size: 13px;
    font-family: var(--sp-font);
    transition: background 0.2s, color 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.sp-portal-nav-item:hover { background: rgba(255,255,255,0.1); color: #fff !important; text-decoration: none !important; }
.sp-portal-nav-item.active { background: var(--sp-cyan); color: #fff !important; }
.sp-portal-nav-logout { margin-left: auto; color: #999 !important; font-size: 12px; }
.sp-portal-nav-logout:hover { color: var(--sp-red) !important; }

.sp-portal-content { max-width: 960px; }
.sp-portal-subtitle { margin: 4px 0 0; color: var(--sp-gray); font-size: 13px; }

/* ─── Back Link ────────────────────────────────────────────────────────────── */
.sp-back-link { font-size: 12px !important; display: block; margin-bottom: 8px; color: var(--sp-gray) !important; font-weight: normal !important; }
.sp-back-link:hover { color: var(--sp-pink) !important; }

/* ─── Pipeline ─────────────────────────────────────────────────────────────── */
.sp-pipeline {
    display: flex;
    align-items: center;
    gap: 0;
    margin-bottom: 20px;
    background: var(--sp-light);
    border: 1px solid var(--sp-border);
    border-radius: var(--sp-radius);
    padding: 12px 16px;
    flex-wrap: wrap;
}
.sp-pipeline-step {
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: bold;
    background: #e0e0e0;
    color: #999;
    white-space: nowrap;
}
.sp-pipeline-step--done {
    background: var(--sp-cyan);
    color: #fff;
}
.sp-pipeline-arrow {
    padding: 0 6px;
    color: #ccc;
    font-size: 16px;
}

/* ─── Card Variants ────────────────────────────────────────────────────────── */
.sp-card--attention {
    border-left: 3px solid var(--sp-pink);
}
.sp-card--link { cursor: pointer; }
.sp-card--link:hover { border-color: var(--sp-cyan); }

.sp-card-action {
    margin-top: 8px;
    font-size: 12px;
    font-weight: bold;
    color: var(--sp-pink);
}

/* ─── Stat Cards ───────────────────────────────────────────────────────────── */
.sp-portal-stats a.sp-stat-card { text-decoration: none !important; color: inherit; }
.sp-portal-stats a.sp-stat-card:hover { box-shadow: 0 4px 16px rgba(0,0,0,0.12); transform: translateY(-2px); }
.sp-stat-card { transition: transform 0.2s, box-shadow 0.2s; }

/* ─── Activity Items ───────────────────────────────────────────────────────── */
a.sp-activity-item { display: flex !important; text-decoration: none !important; color: inherit !important; font-weight: normal !important; }
a.sp-activity-item:hover { background: var(--sp-light); }

@media (max-width: 600px) {
    .sp-portal-nav { flex-direction: column; }
    .sp-portal-nav-logout { margin-left: 0; }
    .sp-pipeline { flex-direction: column; align-items: flex-start; gap: 4px; }
    .sp-pipeline-arrow { display: none; }
    .sp-portal-stats { grid-template-columns: 1fr 1fr !important; }
}
