/* ============================================
   MATWORK THEME - TakeTime Mini App
   Colori e stili coerenti con MatWork
   ============================================ */

:root {
    /* Colori MatWork */
    --primary: #059669;
    --primary-dark: #047857;
    --primary-light: #d1fae5;
    --primary-color: #059669;
    --success-color: #10b981;
    --success-light: #d1fae5;
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --info-color: #3b82f6;
    --info-light: #dbeafe;
    --text-color: var(--tg-theme-text-color, #1e293b);
    --text-muted: #64748b;
    --bg-color: var(--tg-theme-bg-color, #f8fafc);
    --card-bg: var(--tg-theme-secondary-bg-color, #fff);
    --border: #e2e8f0;
    --border-radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.08);
    --gradient-bg: linear-gradient(135deg, #059669 0%, #047857 100%);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    color: var(--text-color);
    background: var(--gradient-bg);
    line-height: 1.6;
    min-height: 100vh;
    position: relative;
}

body::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="none"/><path d="M0,0 L100,100 M100,0 L0,100" stroke="rgba(255,255,255,0.05)" stroke-width="1"/></svg>');
    z-index: -1;
}

.container {
    max-width: 500px;
    margin: 0 auto;
    padding: 24px 16px;
}

/* Header */
.header {
    position: relative;
    margin-bottom: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    padding: 10px 0;
}

.header-content {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    justify-content: center;
}

.logo {
    width: 60px;
    height: 60px;
}

.header h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 4px;
    color: #ffffff;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    text-align: left;
}

.header p {
    color: var(--primary-light);
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    text-align: left;
}

.back-button {
    color: white;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    display: flex;
    align-items: center;
    margin-right: 10px;
}

.back-button i {
    margin-right: 8px;
}

/* Welcome */
.user-welcome, .welcome h1 {
    color: #ffffff;
    text-align: center;
    margin-bottom: 20px;
    font-size: 20px;
    font-weight: 500;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
    background-color: rgba(255, 255, 255, 0.15);
    border-radius: 12px;
    padding: 10px 16px;
    display: inline-block;
}

/* Status Bar */
.status {
    font-size: 16px;
    text-align: center;
    margin-bottom: 28px;
    padding: 16px;
    border-radius: var(--border-radius);
    background-color: var(--card-bg);
    box-shadow: var(--shadow);
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
    font-weight: 500;
    border: 1px solid var(--border);
    color: var(--text-color);
}

.status::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 4px;
    height: 100%;
    background-color: var(--primary);
}

/* Buttons */
.button-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 28px;
    gap: 16px;
}

.button {
    flex: 1;
    padding: 16px 20px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow);
}

.button i {
    margin-right: 8px;
}

.button-enter, .button-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
}

.button-exit, .button-danger {
    background: linear-gradient(135deg, var(--danger-color) 0%, #dc2626 100%);
    color: white;
}

.button-warning {
    background: linear-gradient(135deg, var(--warning-color) 0%, #d97706 100%);
    color: white;
}

.button-secondary {
    background: var(--card-bg);
    color: var(--primary);
    border: 1px solid var(--border);
}

.button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
}

.button:active {
    transform: translateY(1px);
}

.button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Cards */
.card, .history, .work-time-card, .profile-card, .calendar-card, .settings-card {
    background-color: var(--card-bg);
    border-radius: var(--border-radius);
    padding: 20px;
    margin-bottom: 24px;
    box-shadow: var(--shadow);
}

.card-title, .history-title {
    font-size: 18px;
    margin-bottom: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    color: var(--text-color);
}

.card-title i, .history-title i {
    margin-right: 8px;
    color: var(--primary);
}

/* Work Time Display */
.work-time-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.work-time-display {
    font-size: 36px;
    font-weight: 700;
    color: var(--primary);
    margin-bottom: 8px;
}

.work-time-label {
    font-size: 14px;
    color: var(--text-muted);
}

/* Profile/Secondary Buttons */
.profile-button,
.calendar-button,
.absence-button,
.permission-button,
.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    padding: 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 20px;
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow);
}

.profile-button i,
.calendar-button i,
.absence-button i,
.permission-button i,
.action-button i {
    margin-right: 8px;
}

.profile-button:hover,
.calendar-button:hover,
.absence-button:hover,
.permission-button:hover,
.action-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.1);
}

/* Timbrature Badge Style */
.timbrature-oggi-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.timbratura-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.4rem 0.75rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 500;
}

.timbratura-badge.ingresso, .timbratura-badge.enter {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #065f46;
}

.timbratura-badge.uscita, .timbratura-badge.exit {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #991b1b;
}

.timbratura-badge i {
    font-size: 0.9rem;
}

/* History Items */
.history-item {
    padding: 12px 16px;
    border-radius: 12px;
    margin-bottom: 10px;
    background-color: rgba(0, 0, 0, 0.02);
    position: relative;
    transition: all 0.2s ease;
}

.history-item:hover {
    background-color: rgba(0, 0, 0, 0.04);
}

.history-item.enter-type {
    border-left: 3px solid var(--success-color);
}

.history-item.exit-type {
    border-left: 3px solid var(--danger-color);
}

/* Footer */
.footer {
    text-align: center;
    color: rgba(255, 255, 255, 0.9);
    font-size: 14px;
    margin-top: 32px;
    background-color: rgba(255, 255, 255, 0.1);
    padding: 12px;
    border-radius: 12px;
}

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

.form-label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 6px;
}

.form-control, .form-select {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    font-size: 16px;
    transition: all 0.2s;
    background: var(--card-bg);
    color: var(--text-color);
}

.form-control:focus, .form-select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

/* Toggle Switch */
.toggle-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--border);
}

.toggle-label {
    font-size: 16px;
    color: var(--text-color);
}

.toggle-switch {
    position: relative;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: var(--border);
    transition: 0.3s;
    border-radius: 28px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
}

input:checked + .toggle-slider {
    background-color: var(--primary);
}

input:checked + .toggle-slider:before {
    transform: translateX(22px);
}

/* Calendar */
.calendar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.calendar-nav {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--primary);
    cursor: pointer;
    padding: 8px;
}

.calendar-title {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-color);
}

.calendar-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}

.calendar-day-header {
    text-align: center;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 8px 0;
}

.calendar-day {
    aspect-ratio: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.calendar-day:hover {
    background: var(--primary-light);
}

.calendar-day.today {
    background: var(--primary);
    color: white;
    font-weight: 600;
}

.calendar-day.has-entries {
    position: relative;
}

.calendar-day.has-entries::after {
    content: '';
    position: absolute;
    bottom: 4px;
    width: 6px;
    height: 6px;
    background: var(--primary);
    border-radius: 50%;
}

.calendar-day.today.has-entries::after {
    background: white;
}

/* Access Status */
.access-status {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
    text-align: center;
    font-weight: 500;
}

.access-status:empty {
    display: none;
}

.access-status.success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
    display: block;
}

.access-status.error {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
    display: block;
}

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    margin-bottom: 16px;
    font-size: 14px;
}

.alert-success {
    background: var(--success-light);
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.alert-danger {
    background: var(--danger-light);
    color: #991b1b;
    border: 1px solid #fecaca;
}

.alert-warning {
    background: var(--warning-light);
    color: #92400e;
    border: 1px solid #fcd34d;
}

.alert-info {
    background: var(--info-light);
    color: #1e40af;
    border: 1px solid #93c5fd;
}

/* Animations */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

.pulse {
    animation: pulse 2s infinite;
}

/* Responsive */
@media (max-width: 480px) {
    .container {
        padding: 16px 12px;
    }
    
    .header h1 {
        font-size: 20px;
    }
    
    .button {
        padding: 14px 16px;
        font-size: 14px;
    }
    
    .work-time-display {
        font-size: 28px;
    }
}
